Part Number Hot Search : 
272MA3 SDR647CT 1N5229B LTC2641 IRF380 LT1222 4AE055 SCBAR10
Product Description
Full Text Search
 

To Download ST52T301 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
 (R)
ST52T301/E301
8-Bit OTP/EPROM DuaLogicTM MCUs WITH ADC, UART, TIMER, TRIAC & PWM DRIVER
ADVANCED DATA SHEET
High Speed dedicated structures for Fuzzy Logic (3.5 s to compute a 4 In x 1 Out rule) Capability to perform simple boolean and arithmetic operations Up to 4 Input, 2 Output ConfigurableVariables for each Fuzzy Algorithm and up to 300 Rules Up to 16 Triangularand TrapezoidalMembership Functions for each Input variable Up to 256 Singleton Membership Functions for all Consequents Program and Data EPROM: 2 Kbytes 16 general purpose registers available as Register File Working Clock Frequencies: 5, 10 and 20MHz On-Chip Clock Oscillator driven by Quartz Crystal or Ceramic Resonator One external interrupt Standard TTL compatible input CMOS compatible output 4 channel 8 bit Analog to Digital Converter Bandgap reference 2.5V Digital 8 bit I/O port indepedently programmable with handshake signal S e r ial Commu n ic at io n In t erfa ce wit h asynchronous protocol (UART) Programmable Timer with internal Prescaler Internal Power Fuzzy Control to drive external Triac (up to 25mA source, 50 mA sink current) Internal Fuzzy controlled PWM to drive an external power device Software tools and Emulators availability Windowed and One Time Programmable (OTP) Memory parts available for prototyping and production phases 44 pin Plastic (PLCC44) and Ceramic Windowed Leaded Chip Carrier (CLCC44-W)
July 1998
Note: (1) Formerly W.A.R.P.3TC
CLCC44-W
PLCC44
1.1 GENERAL DESCRIPTION ST52E301 (1) and ST52T301 (1) devices are members of the W.A.R.P .family of 8-bit DuaLogicTM microcontrollers. They are able to perform, in an efficient way, both booleanand fuzzy algorithms, in order to reach the best performances that the two methodologies allow. TheST52E301is the erasableEPROMversion and the ST52T301 is the OTP version. The ST52x301 is completely developed and produced by STMicroelectronics using the reliable high performance CMOSM5E (O.7m) process. Thanks to Fuzzy Logic, ST52x301 allows to describe a problemusing a linguistic model instead of a mathematicalmodel.In thisway it is very useful and easy to modelize complex system with very high accuracy. The linguistic approach is based on a set of IF-THEN rules, describing the control behaviour, and on Membership Functions associated to input and output variables. Fuzzy Inference is a set of operations which computes the output values according with the truth values of the involved rules. 1/99
ST52T301/E301
Figure 1. ST52x301 Architectural Block Diagram
ALU FUZZY CORE OSCILLATO R
SYSTEM REGISTERS
CONTROL UNIT
REGISTER FILE
A/D CONVERT ER
BAND-GAP REFERENCE
SCI
PARALLEL I/O PORT
2kBytes EPROM
TRIAC/PWM DRIVE R
PROG.TIMER WITH PRESC ALER
The flexible I/O configuration of ST52x301 allows to interface with a wide range of external devices, like D/A converters, power control devices (SCRs, TRIACs) and external sensors. The OTP (One Time Programmable) device is fully compatible with the EPROM windowed version, which may be used to create prototype systems and for the pre-production phases. The Fuzzy Core includes the fuzzifier (ALPHA calculator), the inference unit and the defuzzifier. It allows to manage up to 300 Rules (4 Inputs and 1 Output). The rules could be shared in different fuzzy subroutines that can be activated by user defined conditions. T he I / O c a p ab ilit ie s, de man d ed f rom microcontroller applications, are fulfilled by ST52x301 with 4 Analog Inputs, an asynchronous Peripheral interface (UART) and an 8-bit I/O communicationport in orderto transferdata from/to the on-chip Register File. The voltage reference provides biasing to the analog portion of the internal circuitry. The internal reference is a 2.5V Bandgap reference. The voltage reference can supply up to 0.1 mA of current to power external circuitry. ST52x301 includes an 8-bit sampling Analog to Dig it al (A/ D) Co n ve r te r wit h a 4 a n a lo g 2/99
channel fast multiplexer (32s c o n ve rs io n time/channel). It is possible to perform operations on data stored in the Register File (16 bytes), allowing to manage new inputs and feedback outputs. The TRIAC/PWM Driver peripheral allows to manage directly power devices, implementing three different operating modes: Burst Mode (i. e.T h e rmal A pp li ca t ion s), Ph a s e A ng le Partialization (i.e. Motors Control by TRIACs) and high frequency PWM controls. A programmable Timer with Internal Prescaler, using both internal or external clock, is available. The microcontroller configuration is stored in the internal EPROM. A p o we rf u l de velo pmen t e nviron me nt , FUZZYSTUDIOTM 3.0, consisting of a board an d s of twa re t ool s, a ll ow s an easy configuration and use of ST52x301. ST 52 x3 0 1 i s f u l ly s up po r t ed b y FUZZYSTUDIO3.0 so f t wa re t o ols a llowin g to gra ph ic ally d es ig n a project and obtain an optimized microcode. ST52x301 exploits a SGS-THOMSON patented strategy to store the MFs in its internal memory.
ST52T301/E301
Figure 2. CLCC44-W Pin Configuration
Figure 3. PLCC44 Pin Configuration
3/99
ST52T301/E301
Table 1. PLCC44 and CLCC44-W Pin Configuration
PIN 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 NAME not connected AVDD AVSS EVDD EVSS VPP VDD VSS P0 P1 P2 P3 P4 P5 P6 P7 READY P8 TEST MAIN2 MAIN1 VDD VSS TRIACOUT MODE RESET CE/INT TIMEROUT ERES / TRES OE / TCTRL OSCout OSCin CADD / TCLK VSS VDD TxD RxD not connected not connected AIN3 AIN2 AIN1 AIN0 BG Ainp Ainp Ainp Ainp Aout O I O I I I O I I I/O I I EPROM Address Counter Reset EPROM Output Enable Oscillator Output Oscillator Input EPROM Change Address Clock Digital Ground Digital Power Supply Functionment Mode Selector General Reset Chip Enable EPROM I/O I/O I/O I/O I/O I/O I/O I/O O O I I/O I Digital Power Supply Digital Ground (must be set to 0) TYPE Programming Phase Analog VDD Analog Ground EPROM Digital Power Supply EPROM Digital Ground EPROM Programming Power supply (12V 5%) Digital Power Supply Digital Ground I/O EPROM Data I/O EPROM Data I/O EPROM Data I/O EPROM Data I/O EPROM Data I/O EPROM Data I/O EPROM Data I/O EPROM Data Working Phase Analog VDD Analog Ground EPROM Digital Power Supply EPROM Digital Ground EPROM V DD (5V 10%) Digital Power Supply Digital Ground Digital I/O Digital I/O Digital I/O Digital I/O Digital I/O Digital I/O Digital I/O Digital I/O I/O port Handshaking Signal Digital Output (must be set to 0) Zero Crossing/Prescaler Output Zero Crossing Digital Power Supply Digital Ground Triac/PWM Driver Output Pulses Functionment Mode Selector General Reset External Interrupt Output Timer External Timer Reset Timer Start/Stop Signal Oscillator Output Oscillator Input Timer External Clock Digital Ground Digital Power Supply SCI Output SCI Input Analog Input Analog Input Analog Input Analog Input Band Gap Output
4/99
ST52T301/E301
1.2 PIN DESCRIPTION VDD, EVDD, VSS, EVSS, AVDD, AVSS, VPP. In order to avoid noise disturbances, the power supply of the digital part is kept separated from the power supply of the analog part. VDD. Main Power Supply Voltage (5V 10%). VSS. Digital circuit Ground. EVDD. EPROM Main Power Supply Voltage (5V 10%). EVSS. EPROM Digital circuit Ground. AVDD. Analog VDD of the Analog to Digital Converter. AVSS.AnalogVSS of theAnalogto DigitalConverter. Must be tied to VSS. VPP. Main Power Supply for the internal EPROM (12.5V 5%). OSCin and OSCout. These pins are internally connected with the on-chip oscillator circuit. A quar tz crystal or a ceramic resonator can be connectedbetween these two pins in order to allow the correct operations of ST52x301 with various stability/cost trade-offs. An external clock signal can be applied to OSCin, in this case OSCout must be grounded. RESET. This signal is used to restart ST52x301 at the beginningof its program.It also allows to select the program mode for the EPROM. INT. External interrupt active on rising or falling edge. AIN0-AIN3. These 4 lines are connected to the inputs of the analog multiplexer. They allow to acquire 4 analog inputs. BG. A Voltageequal to 2.5V is available on this pin. It can be used for Analog signal conditioning. P0-P7. These 8 lines are organizedas one I/O port. During the Programming phase such port is used for the EPROM data read/write. READY. Handshake signal of the parallel port. P8. Digital output. TxD. Serial data output of the SCI transmitter block. RxD. Serial data input of the SCI receiver block. TRES, TCLK, TCTRL, TIMEROUT. These pins are related with the internal Programmable Timer. The Timer can be reset externally by using TRES. In Working Mode, TRES resets the address counter of the Timer. TRES is active at low level The Timer Clock can be the internal clock or can be supplied externally by using the pin TCLK. An external Start/Stopsignal can be used to control the Timer throughthe pin TCTRL.The Timeroutput is available on the pin TIMEROUT. MAIN1, MAIN2, TRIACOUT. ST52x301 is able to drive a TRIAC in two different modes: Burst mode or Phase Angle Partialization control mode. The Burst mode is used for thermal regulation. MAIN1 and MAIN2 signals are used to detect the zero crossing of the main voltage. Thepulse to drivethe TRIACis givenby TRIACOUT pin. It is possible to use the same pins to implement a PWM Driver. In this case it is possible to fix the period of PWM and to changethe duty cycle on fly. The PWM output is given by TRIACOUT pin. CE, OE, ERES, CADD, VPP. These pins are used to manage the EPROM during the Programming p ha s e . Dur in g t h e P ro g ra mming ph a se (programming) VPP must be set at 12V. In the Working phase VPP must be equal to VDD. ERES in Programming Mode resets the address counter of the EPROM; it is active at high level. In the Working phase OE, CE and CADD are used like handshaking signals for the parallel port. MODE. I t s elec ts t h e fun ct ion ment mo d e (Programming or Working mode). TEST. It enables the testing functionalities; during the Programming and Working phaseit must be set to 0.
5/99
ST52T301/E301
2 INTERNAL ARCHITECTURE ST52x301 is made up by the following blocks and peripherals: Control Unit Fuzzy Core ALU EPROM Clock Oscillator Analog Multiplexer and A/D Converter Prescaler Timer Bandgap Triac / PWM Driver Digital I/O port Serial Communication Interface ST52x301 Operating Modes ST52x301 works in two modes, Programming and Working Modes, depending on the control signals level RESET, TEST and MODE. The Operating modes are selected by setting the control signal level as specified in the Control Signals Setting table. 2.1 CONTROL UNIT The Control Unit (CU) manages: Registers File, Input Registers, Configuration Registers, ALU, Accumulator and Multiplexer inputs. Moreover the CU drives the Fuzzy Core and the peripherals (Triac/PWM Driver and Timer). The CU reads the stored instructions on the EPROM (Fetch) and decodifies them. If the instructions are arithmetic or logic, the CU runs them directly, sending the control signals to the related blocks. If there is a STOP instruction, the CU transfers the control to the Fuzzy Core. The Fuzzy Core (FC) will read the next instruction (that must be a fuzzy instruction)from the EPROM. The FC mantains the control of the program until the next STOP instruction. Then the FC transfers the control to the CU. These characteristicsallow to mix fuzzy algorithms with mathematical and logic instructions. Figure 2.1 shows a flow-chart reasuming the logic behaviour of the instructions management. Table 2.1. Control Signals setting
Control Signal RESET TEST MODE Programming 0 0 1 Reset 0 0 0 Working 1 0 0
Figure 2.1. Computation Algorithm Flow Chart
CU Reads fromthe EPROM and Decodifies the instruction
STOP?
No
CU executes instruction
Yes
Fuzzy Core Reads fromthe EPROM and Decodifies the instruction
Yes
STOP?
No
Fuzzy Core executes instruction
6/99
ST52T301/E301
Figure 2.2. ST52x301 Block Diagram
TxD RxD P0..P7 P8 READY
SCI (UART)
MAIN1 TRIAC/PWM DRIVER TRIACOUT MAIN2
I/O PARALLEL PORT
TCTRL AIN0..AIN3 8 BIT A/D CONVERTER TRES TIMER TCLK EPROM 2 KBytes TIMEROUT
CONTROL UNIT
Peripheral Register
PERIPH_REG_0 PERIPH_REG_1 PERIPH_REG_2
PC FL AGS
ALU
Input Registers
ADC_OUT_0 ADC_OUT_1 ADC_OUT_2 ADC_OUT_3 TMR_OUT TMR_ADC_ST INP_PORT SCI_IN SCI_ST FUZZY_OUT_0 FUZZY_OUT_1
Register File
Reg 0 Reg 1 Reg 15
FUZZY CORE
Configuration Registers
REG_CONF0 REG_CONF1 REG_CONF15
POW ER SUPPLY
OSCILLATOR
RESET
VDD VPP VSS
OSCin
OSCout
RESET
7/99
ST52T301/E301
It is not possibile to stop the fuzzy inference before the end of the defuzzificationof one output.Aset of 26 different arithmetic and logic instructions is available.Each instruction requiresfrom4 to7 clock pulses to be performed. 2.1.1 Program Counter The Program Counter (PC) is a 11-bit register that contains the address of the next memory location to be processed by the core.This memory location may be an opcode,an operand or an address of an operand. The 11-bit length allows the direct addressing mode of 2048 bytes in the program space. After having read the current instruction address, the PC value is incremented. To execute relative jumps the PC and the offset are shiftedthrough the Fuzzy Core or the ALU, where they will be added. The result of this operation is shifted back into the PC. The PC can be changed in the following ways: JP (Jump) instruction PC = Jump Address Interrupt RETI instruction Reset Normal Instruction PC = Interrupt Vector PC = Pop (stack) PC = Reset Vector PC = PC + 1 The Carry flag is set when a carry or a borrow occurs during arithmetic operations, otherwise it is cleared. The switching between the two sets of flags is automatically performed when an interrupt or a RETI instruction occur. 2.2 ADDRESS SPACES W.A.R.P3TC has four separate address spaces: Register File: 16 8-bit registers Input Registers:11 8-bit registers Configuration Registers: 16 8-bit registers Peripheral Registers: 3 8-bit registers Program memory up to 2K Bytes The Program memory will be described in further detail in the MEMORYsection 2.2.1 Register File The Register File (RF) consists of 16 general purpose 8-bit registers Reg0 to Reg15. All the registers in the RF can be specifiedby using a decimal address, e.g. 0 identify the first register of the RF, called Reg0. Reg0:3 are directly connected to the FC input. It means that the input values of the fuzzy algorithm must be loaded into these registers by the user. These registers are used as temporary registers during the macros' computation.
2.1.2 Flags The ST52x301 core includes two pairs of flags that correspond to 2 different modes: normal mode and interrupt mode. Each pair consist of a CARRY flag and a ZERO flag. One pair (CN, ZN) is used during normal operation and one is used during the interrupt mode (CI, ZI). The ST52x301 core uses the pair of flags that correspond to the actual mode: as soon as an interrupt is generated,the ST52x301 core uses the interrupt flagsinstead of the normal flags.When the RETI instruction is executed the normal flags are restored if the MCU was in the normal mode before the interrupt. It should be observed that each flag set can only be addressed in its own routine. The flags are not cleared during the context switching and remain in the state they were at the exit of the last routine switching.
8/99
ST52T301/E301
Figure 2.3. Address Spaces description
CORE P ro gra m M e m o ry
O N -C H IP P E RIP H E R A L S C o n fig u ra tio n R e g isters
LDC F
In p u t R e gis te rs
AL U F U Z ZY
R e g ister F ile P e rip h er al R e g isters
P E R IP H E R A L B L OC K
C OR E LDP R
LD R I
LD R C
LD R R
(1 )
L D C F C R i, x
Figure 2.4. Register File description
Register File
Register Reg0 Reg1 Reg2 Reg3 Reg4 Reg5 Reg6 Reg7 Reg8 Reg9 Reg10 Reg11 Reg12 Reg13 Reg14 Reg15 Description FUZZY_IN_0 FUZZY_IN_1 FUZZY_IN_2 FUZZY_IN_3 Free Free Free Free Free Free Free Free Free Free Free Free
Fuzzy Core
9/99
ST52T301/E301
2.2.2 Input Registers Bench The Input Registers (IR) bench consists of 11 8-bit registers co ntaining data or status of t he peripherals. All the registers can be specifiedby using a decimal address, e.g. 0 identifies the first register of the IR. The first four registers (ADC_OUT_0:3) of the IR are dedicated to the 4 converted values coming from the ADC. TMR_OUT registers contains the current counted value by the internal Timer; whereas TMR_ST is the Timer status. For details about TMR_ST, please refer to Timer description. Data read by the Parallel I/O Port are stored automatically in the 6-th register, INP_PORT. Data read by the SCI are stored automatically in the 7-th register SCI_IN and SCI status is stored in the SCI_ST register. For details about SCI_ST, please refer to SCI description. The Fuzzy Core writes the computed output values in the FUZZY_OUT_0:1 registers.
Figure 2.5. Input Registers Bench description
10/99
ST52T301/E301
Figure 2.6. TMR_ADC_ST Registers
Figure 2.7. SCI_ST Registers
11/99
ST52T301/E301
2.2.3 Configuration Registers The ST52x301 setting permits to configure all blocks.Table 2.2 describesthe relatedblock to each bit of the Configuration Registers. Use and meaning of each register will be described in further details in the corresponding section. Table 2.2. Configuration Registers description
Register REG_CONF0 Peripheral PARALLEL PORT SCI, CORE, I/O PORT ADC Bit 7 IO7 Bit 6 IO6 Bit 5 IO5 Bit 4 IO4 Bit 3 IO3 Bit 2 IO2 Bit 1 IO1 Bit 0 IO0
REG_CONF1
RDRF
OVR
BRK
TDRE
TXC
ECKF
P8 OUT
REG_CONF2
not used
IADD
1
ADRST
REG_CONF3
SCI
BRSL
T8
M
RE
TE
REG_CONF4
TIMER
TMLSB
REG_CONF5
TIMER
TMMSB
REG_CONF6
TIMER
not used
POL
TMS
CKSL
TMEL
IESL
TMST
TMRST
REG_CONF7
TIMER
not used
FZSL
INPSL
INTR
INTF
INTSL
REG_CONF8
TRIAC
TCLSB
REG_CONF9
TRIAC
TCMSB
REG_CONF10
TRIAC
IOSL
PSF
CKSL
MODE
TCST
TCRST
REG_CONF11
TRIAC
INTSL
TCMSK
TCTRS
POL
REG_CONF12
TRIAC
FZSL
INPSL
UTPMSB
REG_CONF13
TRIAC
UTPLSB
REG_CONF14
INTERRUPT
EXTI
not used
MSKTC
MSKTM
MSKSCI
MSKAD
MSKE
REG_CONF15
INTERRUPT
INT4
INT3
INT2
INT1
12/99
ST52T301/E301
2.2.4 Peripheral Registers Periph eral Registers contain the initialization values for the Timer, Triac/PWM Driver and Parallel Port. The peripheral initialization value is kept from a location of the Register File, by using a LDPR instruction, or from FUZZY_OUT_0/1 Input Register according with the related Configuration Registers. Table 2.3 describes the related peripheral to each Configuration Register. Use and meaning of each register will be described in further details in the corresponding section.
Table 2.3. Peripheral Register description
Peripheral Register PERIPH_REG_0 PERIPH_REG_1 PERIPH_REG_2 Timer Triac/PWM Driver Parallel Port Peripheral
13/99
ST52T301/E301
2.4 FUZZY CORE ST52x301 Fuzzy Core main features are: Up to 4 Inputs with 8-bit resolution Up to 16 Membership Functions (Mbfs) for each Input (64 possible Mbfs) Up to 2 Outputs with 8-bit resolution Possibility to process fuzzy rules with a max. number of 8 antecedents 2.4.1 Internal Structure The block diagram shown in figure 2.9 describes the structure of ST52x301Fuzzy Core.In this figure we can distinguishdifferentfunctionalblocks:Alpha Calculator, Inference Unit and Defuzzifier. These blocks allow to perform a MAMDANI type fuzzy inference with crisp consequents.It is important to underline that the fuzzy inference is performed by using as inputs the first 4 locationsof the Registers File. 2.4.2 Alpha Calculator Unit This block performs the intersection (alpha weight) between the input values and the related Mbfs (fig. 2.8). Figure 2.9. Fuzzy Core Block Diagram
j-th Mbf 1
Figure 2.8. Alpha Weigth calculation
ij
i-th INPUT VARIABLE Input Value
Notice that the inputs for this block come from the first four locations of the Register File; it means the user, to evaluate a fuzzy function, must load the input values in these registers. Alpha Calculato r pe rforms what is called fuzzification: the input data are transformed in activation level (alpha weight) of the Mbfs.
14/99
ST52T301/E301
2.4.3 Inference Unit It managesthe alphaweights obtainedby the Alpha Calculator Unit to compute the truth value ( ) for each rule. This is a calculation of the maximum (for the OR operator) and/or minimum (for the AND operator) performed on alpha values according to the logical connectives of fuzzy rules. It is possibile to link together up to eight conditions by linguistic connectives AND/OR, NOT operator and brackets. Each rule can have at maximum 8 alpha weights (however they are connected). The truth value and the related output singleton are passed to the Defuzzifier to complete the inference calculation. Figure 2.11.
j-th Singleton
1 ij i0 in
0
Xi0
Xij
Xin
i-th OUTPUT VARIABLE
Figure 2.10. 2.4.4 Defuzzifier This block consists of a Multiplier, two Adders and one Divider. It generates the output crisp values implementing the consequent part of the rules. In this phase each consequent Singleton Xi is multiplied by its weight values i, calculated by the Inference Unit in order to compute the upper part of the defuzzification. Each output value (FUZZY_OUT0, FUZZY_OUT1) is deduced from the consequent crisp values (Xi) by using the defuzzification formula:
N
IF INPUT 1 IS X1 OR INPUT 2 IS X2 THEN .......
1 2 X1
Input 1
X2
Input 2
OR = Max
IF INPUT 1 IS X1 AND INPUT 2 IS X2 THEN .......
1 2 X1
Input 1
Xij ij
Yi =
j
X2
Input 2
ij
j
N
where: i = 0,1 identifies the current output variable N = number of the active rules on the current output ij =weigth of the j-th singleton Xij = abscissa of the j-th singleton The two fuzzy outputs are stored in the location 9 and 10 of the Input Registers (FUZZY_OUT_0, FUZZY_OUT_1).
15/99
ST52T301/E301
2.4.5 Input Membership Function ST52x301 allows to manage triangular Mbfs. In order to define a Mbf it is necessary to store three different data on the memory: the vertex of the Mbf: V; the lenght of the left semi-base: LVD; the lenght of the right semi-base: RVD; In order to reduce the dimension of the memory area and the computational effort the vertical dimension of the vertex is fixed to 15 (4 bits) By using the previous memorization method it is possible to store different kinds of triangular Memberships Functions. In the following figure is shown a typical example of Mbfs that can be defined in ST52x301 Each Mbf is then defined storing 3 bytes. To store all the information related with the fuzzy project Mbfs, it is necessary to use 192 bytes of the memory (3 bytes*16 Mbfs*4 Inputs = 192 bytes). The Mbf is memorized by using the following instruction:
DATA n m lvd v rvd where n identifies the input, m identifies the Mbf among the 16 possibleMbfs, lvd, v, rvd are the parameters describing the Mbf's shape. 2.4.6 Output Singleton ST52x301uses for the output variables a particular kind of membership function called Singleton. A Singleton has not a shape, like a traditional Mbf, and it is characterized by a single point identified by the couple (X, ), where the is calculated by the Inference Unit as described before. Often a Singleton is simply identified with its Crisp Value X.
Figure 2.12. Mbfs Parameters
Figure 2.13. Example of valid Mbfs
15
Input Mbf
0
V LVD
Input Variable RVD
15 w
Output Singleton
0
X
Output Variable
16/99
ST52T301/E301
2.4.7 Fuzzy Rules. The rules can have the following structures: if A op B op C...........thenZ if (A op B) op ( C op D op E...) ...........thenZ where op is one of the possible linguistic operators (AND/OR) In the first case the rule operators are managed sequentially; in the second one, the priority of the operator is fixed by the brakets. Each rule is codified by using an istruction set, the inference time for a rule with 4 antecedents and 1 consequent is about 3 microseconds. The assembler Instruction Set allowing to manage the fuzzy instructions are reported in the following table:
Table 2.4. Fuzzy Instructions Set
Instruction DATA n m lvd v rvd Description Stores the Mbf m of the input n with the shape identified by the parameters lvd, v and rvd.
LDP n m
Fixes the alpha value of the input n with the Mbf m and stores it in the data stack.
LDN n m
Calculates the negated alpha value of the input n with the Mbf m and store the result in the data stack.
FZAND
Implements the fuzzy operation AND between the last two values stored in the data stack.
FZOR
Implements the fuzzy operation OR between the last two values stored in the data stack.
LDK
Stores the result of the last fuzzy operation executed in the data stack.
SKM
Stores the result of the last fuzzy operation executed in the memory register M.
LDM
Copies the value of the register M in the data stack.
CON crisp
Multiplies the crisp value with the last weight.
OUT n_out
Performs the defuzzification.
STOP
Ends the fuzzy algorithm.
17/99
ST52T301/E301
Example 1: IF Input1 IS NOT Mbf1 AND Input4 is Mbf12 OR Input3 IS Mbf8 THEN Crisp1 is codified by the following instructions LDN 1 1 calculates the NOT value of Input1 with Mbf1 and stores the result in the data stack LDP 4 12 fixes the value of Input4 with M12 and stores the result in the data stack FZAND adds the NOT and values obtained with the operations LDN1 1 and LDP 4 12 LDK stores the result of the operation FZAND in the data stack LDP 3 8 fixes the value of Input3 with Mbf8 and stores the result in the data stack FZOR implements the operation OR between the results obtained with the operations LDK and LDP CON crisp1 multiplies the result of the last operation with the crisp value Crisp1 Example 2, the priority of the operator is fixed by the brakets: IF (Input3 IS Mbf1 AND Input4 IS NOT Mbf15) OR (Input1 IS Mbf6 OR Input6IS NOT Mbf14) THEN Crisp2 LDP 3 1 LDN 4 15 FZAND SKM LDP 1 6 LDN 2 14 FZOR LDK LDM FZOR CON crips2 fixes the value of Input3 with Mbf1 and stores the result in the data stack calculates the NOT value of Input4 with Mbf15 and stores the result in the data stack adds NOT and values obtained with the operations LDP 3 1 and LDN 4 15 stores the result of the operation FZAND in the memory register M fixes the value of Input1 with Mbf6 and stores the result in the data stack calculates the NOT value of Input6 with Mbf14 and stores the result in the data stack implements the operation OR between the and NOT values obtained with the two previous operations (LDP 1 6 and LDN 2 14) stores the result of the operation OR in the data stack copies the value of the memory register M in the data stack implements the operation OR between the last two values stored in the data stack (LDK and LDM) multiplies the result of the last operation with the crisp value Crip2
At the end of the fuzzy rules set a byte, to identify the output involved in the rules, and the STOP istruction must be inserted. When the STOP instruction is performed, the control of the algorithm goes back to the CU.
18/99
ST52T301/E301
2.5 ARITHMETIC LOGIC UNIT The 8-bit Arithmetic Logic Unit (ALU) allows to perfo rm arit hme tic calcu la tions and logic instructions which can be divided into 4 groups: Load, Arithmetic, Jump and Program Control instructions (refer to the ST52x301 Assembler Set for further details ). Table 2.5. Arithmetic & Logic Instructions Set
Load Instructions Menmonic LDCF LDRC LDRI LDPR LDRR Instruction LDCF conf, const LDRC reg, const LDRI reg, inp LDPR per, reg LDRR regi, regj Bytes 2 2 2 1 2 Arithmetic Instructions Mnemonic ADD AND SUB SUBO Instruction ADD regi, regj AND regi, regj SUB regi, regj SUBO regi, regj Bytes 2 2 2 2 Jump Instructions Mnemonic JP JPNS JPNZ JPS JPZ Instruction JP addr JPNS addr JPNZ addr JPS addr JPZ addr Bytes 2 2 2 2 2 SCI Instructions Mnemonic SRX STX Instruction SRX regi STX regi Bytes 2 2 Cycles 5 5 Z S Cycles 6 6 6 6 6 Z S Cycles 7 7 7 7 Z I I I I S I I I Cycles 6 6 6 6 6 Z S -
The computation al time required for each instruction consists of one clock pulse for each Cycle plus 3 clock pulses for the decoding phase.
Notes: I affected - not affected
19/99
ST52T301/E301
Table 2.6. Arithmetic & Logic Instructions Set (Continue)
Program Control Instructions Mnemonic RETI RINT STOP WAITI UDGI UEGI MDGI MEGI IRQ IRQM IRQP Instruction RETI RINT int STOP WAITI UDGI UEGI MDGI MEGI IRQ int label IRQM mask IRQP cost Bytes 1 1 1 1 1 1 1 1 2 2 2 Cycles 5 4 4 4 4 4 4 4 6 6 6 Z I S I -
Notes: I affected - not affected
20/99
ST52T301/E301
3 EPROM The EPRO M memory provides an on-chip user-programmable non-volatile memory, that allows fast and reliable storage of user data. There are 16K bits of memory space with an 8-bit internal parallelism (2Kbytes) addressed by an 11-bit bus. The data bus is of 8 bits. The memory has a double supply: VPP is equal to 12V5% in Programming Phase and 5V10% during Working Phase.VDD is equal to 5V10%. The EPROM memory of ST52x301 is divided in three main blocks (see Figure 3.1): Mbfs Setting with (0 through 191) contains the coordinates of the vertexes of every Mbf defined in the program. Interrupt Vectors (192 through 201) contain the addresses for the interrupt routines. Each address is composed of two bytes. Program Instruction Set (202 through 2048) contains the instruction set of the user program. It can be composed of more Boolean and Fuzzy Algorithms The operation that can be performed, during Programming Phase, on the EPROM are: Writing, Verify, Writing Inhibit, Standby and Erasing. Fig u re 3 . 2 s h ows t h e s ign a ls t imin g in Programming Mode. Figure 3.1. Memory Map
2048
Fuzzy Algorithm
3.1 EPROM Programming Phase Procedure Programming mode is selected by applying 12V5% voltage to the VPP pin and set the control signal as following: RESET: 0, TEST: 0, MODE: 1. CADD, ERES, OE and CE are the control signals used during the Programming Mode. CADD is active on edge, the others are active on level (OE, CE are active low, ERES is active high). 3.1.1 EPROM Writing When the memory is blank, all the bits are at logic level "1". The data are introduced by programming only the zeros in the desired memory location; however all input data must contain both "1" and "0". The only way to change "0" into "1" is to erase the whole memory ( by exposure to Ultra Violet light) and reprogram it. The memory is in Writing mode when: CE = LOW OE = HIGH with stable data on the data bus P(0:7). The total programming pulse width (CE = 0 V) is, typically, 50 s (by means of 5 pulses of 10 s), but beforeactivating such pulse, it is suggested to wait for at least 2 s after VPP rises at 12 V . After the disactivation of the pulse it is suggested to wait for
Boolean Algorithm * *** ** Fuzzy Algorithm Program InstructionsSet
Boolean Algorithm
202 201
192 191
INT_EXT INT_TRIAC INT_TIMER INT_SCI INT_ADC
Interrupt Vectors
Mbf Parameters
Mbfs Setting
0
21/99
ST52T301/E301
at least 2 s before updating the data and the address. The data updating for the next programming is performed, directly by the user, on the data bus P(0:7) while the address is incremented through the pin CADD. 3.1.2 EPROM Verify A Verify mode is available in order to verify the correctness of the data written. It is possible to activate the Verify mode immediately after the writing of each byte: CE = HIGH OE = LOW Then, if any error in writing occured, the user has to repeat the EPROM writing. The data, during this phase, are avalaible on the bus P(0:7) 3.1.3 Writing Inhibit It occurs between the Writing and Verify Mode: CE = HIGH OE = HIGH 3.1.4 Standby Mode The EPROM has a standby mode which reduces the active current from 10mA (Programming mode) Figure 3.2. EPROM Programming Timing
Writing Inhibit Verify
to less than 100 A. The Memory is placed in standby mode by setting CE at HIGH Logic Level (VPP might be equal to 5 V too). When in standby mode, the outputs are in high impedance state. 3.2 Eprom Erasure Thanks to the transparent window present in the CLCC44-W package, its memory contents may be erased by exposure to UV light. Erasure begins when the device is exposed to light with a wavelengthshorter than 4000A.It should be noted that sunlight, as well as some types of artificial light, includes wavelengths in the 3000-4000A range which, on prolonged exposure, can cause erasure of memory contents. It is thus recommended that EPROM devices be fitted with an opaque label over the window area in order to prevent unintentional erasure. The recommended erasure procedure for EPROM devices consists of exposureto short wave UV light having a wavelength of 2537A. The minimum recommended integrated dose (int ensity x exp o-su re t ime) f or co mplet e era su re is 15Wsec/cm 2 . This is equivalent to an erasure time of 15-20 minutes using a UV source having an intensity of 12mW/cm 2 at a distance of 25mm (1 inch) from the device window.
P(0:7)
DATA IN INPUT PORT 50us typ. 3us min. 2us typ.
DATA OUT
CE
OUTPUT PORT
min 2us
OE CADD
ERES
RESET
12V
VPP
5V
22/99
ST52T301/E301
4 INTERRUPTS The Control Unit (CU) responds to peripheral events and external events through its interrupt channels. When such an event occurs, if it is not maskedand according to a priority order, the current program execution can be suspended to allow the CU to execute a specific response routine. Each interrupt is associated with an interrupt vector that contains the memory address of the related interrupt service routine. Each vector is located in the Program Space (EPROM Memory) at a fixed address (see Interrupt Vectors table fig. 4.2). 4.1 Interrupt Functionment If, at the end of an arithmetic or logic instruction, there are pending interrupts, the one with the highest priority is passed. To pass an interrupt means to store the arithmetic flags and the current PC in the stack and execute the associated Interrupt routine, whose address is located in one of the EPROM memory location between address 192 and 201. The Interruptroutine is performedas a normal code checking, at the end of each instruction, if a higher priority interrupt has to be passed. An Interrupt request with the higher priority stops the lower priority Interrupt. The Program Counter and the arithmetic flags are stored in the stack. With the instruction RETI (Return from Interrupt) the arithmetic flags and Program Counter (PC) are restored from the top of the stack.This stack, used for the Interrupt priority, is a LIFO queue. An Interrupt request cannot stop the processing of the fuzzy rules but this is passed only after the definitionof the fuzzy output or at the end of a logic or arithmetic instruction. 4.2 Global Interrupt Request Enabling When an Interrupt occurs, it generates a Global Interrupt Pending (GIP), that can be hanged up by software. After a GIP a Global Interrupt Request (GIR) will be generate and Interrupt Service Routine associated to the interrupt with higher priority will start. In order to avoid possible conflicts between interrupt masking set in the main program or inside macros, the GIP is hanged up through the User Global Interrup Mask or the Macro Global Interrup Mask (see fig.4.3). UEGI/UDGI instruction switches on/off the User GlobalInterrup Mask enabling/disablingthe GIR for the main program. MEGI/MDGI instructions set the Macro Global Interrupt Mask in order to assure that the macro will not be broken.
Figure 4.1. Interrupt Flow
NORMAL PROGRAM FLOW INTERRUPT SERVICE ROUTINE
INTERRUPT
RETI INSTRUCTION
Figure 4.2. Interrupt Vectors Mapping
202 201 200 199 198 197 196 195 194 193 192 191
INT_EXT
INT_TRIAC
INT_TIMER
Interrupt Vectors
INT_SCI
INT_ADC
Figure 4.3. Global Interrupt Request generation
Global Interrupt Pending User Global Interrupt Mask Macro Global Interrupt Mask Global Interrupt Request
23/99
ST52T301/E301
4.3 Interrupt Sources ST52x301manages interrupt signals generated by the internal peripherals (Timer, Triac/PWM Driver,Analog to Digital Converter and Serial Communication Port) or coming from the INT pin. Th e p o la rit y of t he Ext ern al I nt erru pt is programmed by the EXTI bit of the REG_CONF14 (see Table 4.1 and fig. 4.4). EXTI=0 means that INT_EXT is active on rising edge, otherwise it is active on falling edge. Each peripheral can be programmed in order to generate the associate interrupt;further detailsare described in the related chapter. 4.4 Interrupt Maskability The interrupts can be masked by configuring the REG_CONF14. The interrupt is enabled when the bit associated to the mask interrupt is "1". Viceversa, when the bit is "0", the interrupt is masked and is kept pendent. For example LDCF 14, 6 (CONF_REG14 =00000110) enables interrupts coming from the ADC (INT_ADC) and from the SCI (INT_SCI). 4.5 Interrupt Priority Six priority levels are available: level 5 has the lowest priority, level 0 has the highest priority. Level 5 is associated to the Main Program, levels 4 to 1 are programmable by means of the priority register called REG_CONF15 (see fig.4.5); whereas the higher level is related to the external interrupt (INT_EXT). Timer, Triac/PWM Driver, SCI and ADC are identified by a two bits Peripheral Code (see Table 4.2); in order to set the i-th priority level the user must write the peripheral label i in the related INTi priority level.
4 MSKTC 1 5 6 7 not used not used EXTI 1 Active on Falling Edge 0 Active on Rising Edge TRIAC/ PWM Interrupt Not Masked 2 MSKSCI 1 SCI Interrupt Not Masked TIMER Interrupt Masked TIMER Interrupt Not Masked TRIAC/ PWM Interrupt Masked
Table 4.1. Configuration Register 14 Description
Bit Name Value 0 0 MSKE 1 External Interrupt Not Masked A/D Converter Interrupt Masked A/D Converter Interrupt Not Masked SCI Interrupt Masked Description External Interrupt Masked
0 1 MSKAD 1
0
0 3 MSKTM 1
0
Table 4.2. Interrupts Description
Name INT_EXT INT_ADC INT_SCI INT_TIMER INT_TRIAC Description External Interrupt (INT) ADC SCI TIMER TRIAC Ext Int Int Int Int Priority Highest Programmable Programmable Programmable Programmable Peripheral Code 00 01 10 11 Maskable yes yes yes yes yes EPROM Locations 200-201 192-193 194-195 196-197 198-199
24/99
ST52T301/E301
Figure 4.4. Interrupt Configuration Register 14
REG_CONF14 Interrupt
D7 D6 D5 D4 D3 D2 D1 D0
MSKE - External Interrupt Mask
MSKAD - ADC Interrupt Mask MSKSCI - SCI Interrupt Mask MSKTM - TIMER Interrupt Mask MSKTC - TRIAC Interrupt Mask not used not used EXTI - External Interrupt Polarity
Figure 4.5. Interrupt Configuration Register 15
REG_CONF15 Interrupt
D7 D6 D5 D4 D3 D2 D1 D0
INT1 INT2 INT3 INT4 - HIGH Level Interrupt - MEDIUM-HIGH Level Interrupt - MEDIUM-LOW Level Interrupt - LOW Level Interrupt
25/99
ST52T301/E301
i.e. LDCF 15, 201 (REG_CONF15=11001001) define the following priority levels: Level 1: INT_SCI(SCI Code: 01) Level 2: INT_TIMER(TIMER Code: 10) Level 3: INT_ADC(ADC Code: 00) Level 4: INT_TRIAC(TRIAC Code: 11) When a source provides an Interrupt request, and the request processing is also enabled, the CU changes the normal sequential flow of a program by transfering programcontrol to a selectedservice routine. Whenan interrupt occurs the CU executes a JUMP instruction to the address loaded in the related location of the Interrupt Vector Whenthe executionreturns to the original program, it begins immediately following the interrupted instruction. 4.6 Interrupt RESET An eventually pending interrupts can be reset with the instruction RINT inti which resets the i-th interrupt Figure 4.6. Example of a Sequence of Interrupt Requests Table 4.3. Configuration Register 15 Description
Bit 0, 1 2, 3 4, 5 6, 7 Name INT1 INT2 INT3 INT4 Value Peripheral Code Peripheral Code Peripheral Code Peripheral Code High Medium-High Medium-Low Low Level
26/99
ST52T301/E301
5 CLOCK ST52x301 can work by using a 5, 10 or 20 MHz clock. The ST52x301 Clock Generator module generates the internal clock for the internal Control Unit, ALU, Fuzzy Core and on-chip peripherals and it is designed to require a minimum of external components. The system clock may be generatedby using either a qua rtz cr ystal, or a cera mic res onat or (CERALOC); or, at least, by means of an external clock. The different clock generator options connection methods are shown in Figure 5.1. When an external clock is used, it must be connectedon the pin OSCin while OSCout must be grounded. The crystal oscillator start-up time is a function of manyvariables:crystal parameters(especially RS), oscillator load capacitance (CL), IC parameters, ambient temperature, supply voltage. It must be observed that the crystal or ceramic leads and circuit connections must be as short as possible. Typical values for CL1, CL2 are 10pF for a 20 MHz crystal.
Figure 5.1. Oscillator Connections
27/99
ST52T301/E301
6. A/D CONVERTER The A/D Converter of ST52x301 is an 8-bit analog to digital converter with up to 4 analog inputs offering 8 bit resolution with a total accuracy of 2 LSB and a typical conversion time of 32 s. The conversion range is 0 - 2.5 V. The A/D peripheral converts the input voltage with a process of successive approximations using a fixed clock frequency derived from the oscillator. The ADC uses 5 registers: one Configuration Register, REG_CONF2, and four Data Registers. These 4 registers are the first 4 Input Registers. The A/D converter drives the analog Multiplexer in order to sequentially pick up the external inputs to be put in output and stored automatically in 4 8-bit registers. It is possibile to configurethe Multiplexer by means of the register REG_CONF2, in order to select the number of analog inputs to convert. For example, if the bit 3 and bit 2 of REG_CONF2 are configured at 10, then the Multiplexer will sequentially pick up only the inputs 0,1 and 2. Table 6.1 shows the convertion sequences according to the possible values of the two bit REG_CONF2 (3:2). Figure 6.1. A/D Converter Structure The A/D Converter, at the end of the conversion, will send a signal (end-of-conversion)which can be used like an interrupt signal. The user can select the priority of the A/D interrupt and mask it (see "Interrupt Routine" chapter) Th e co nve rs io n s ta r t s writ ing "1" on REG_CONF2(0). The A/D is reset by writing "0" in REG_CONF2(0). The converted data are automaticallystored in four 8-bit Input Registers. By performing an instruction: LDRI regj ingi the analog input "ingi" is loadedin theregister"regj" of the Register File. Table 6.1.
CONF_REG2 (3:2) 00 01 10 11 INPUT SEQUENCE Ain0 Ain 0, Ain1 Ain 0, Ain 1, Ain 2 Ain 0, Ain 1, Ain 2, Ain 3
28/99
ST52T301/E301
The power consumption of the device can be reduced by turning off the A/D converter, To switch off the A/D converter the CONF_REG2(0) bit must be reset to "0". The A/D Converter features a sample and hold. The input voltage Ain, which has to be converted must be constant, for 12.8 s. An internal bandgap reference is available on pin 44, BG. By using this signal as reference for the signal to be converted, the conversion accuracy is not strongly related with the variation of the power supply. The power supply of the A/D converter (AVDD and AVSS ) in order to avoid interferences is mantained separated from the power supply of the digital core.
Figure 6.2. Configuration Register REG_CONF2
ADC Configuration Register REG_CONF2
D7 D6 D5 D4 D3 D2 D1 D0
Reset ADC Must be 1 ADC input selection Not used
29/99
ST52T301/E301
7.TIMER ST52x301 offers one on-chip Timer peripheral. TheTimer consists of an 8-bit counter with a 16-bit programmable prescaler, thus giving a maximum count o f 224, and control logic that allows configuring the functionment and the type of peripheral outputs. Figure 7.2 shows the Timer block diagram and Figure 7.3 shows the internal structure of the Timer. The content of the 8-bit counter can be read/written and is incrementedon the Rising Edge of the 16-bit prescaler output (PRESCOUT). Moreover, it can be read under program control at any instant of the counting phase and loaded in a location of the Register File. The prescaler can be given any value between 0 and FFFFh setting the 4-th (TMLSB) and 5-th (TMMSB) locations of the Configuration Registers Bench. 7.1 Timer Functionment The Timer requires three signals: TMRCLK, TRST and TSTART (see Figure 7.3). Each of them can be generated internally or externally, this possibility is programmable by the user. TMRCLK increments the counted value of the Presc ale r. It can b e, by se tting CKSL of REG_CONF6 register, the internal clock signal (CLKM) or the signal provided on the pin TCLK. TRST resets to zero the contentof the 8 bit counter. It is generated by the TRES or RESET external signals or it is forcedby TMRSTbit of REG_CONF6 register. Figure 7.1. Timer Functionalities TSTART starts/stops the Prescaler counting.It can be given on the pin TCTRL or it is forced by TMST bit of REG_CONF6 register. The TSTART signal allows to work in two different modes: LEVEL (Time Counter): If the TSTART signal is high the Timer starts the count. When the TSTART is low the count is stopped and the current value is stored in the TMR_OUT register of the Input register Bench, then it can be transferred to the j-th location of the Registers File by using the instruction: LDRI reg-j 4 EDGE(Period Counter): After the reset, when the first edge of the TSTART signal appears, the Timer starts the count, at the next TSTART the Timer is stopped. In this way it is possible to measure the period of an external signal. The functionment modality is set by the TMEL configuration bit of REG_CONF6 register. The starting value of the Counter can be either a value contained in the Register File or directly a Fuzzy Output. If INPSL (REG_CONF7(3)) is set to "1" then the value comes from one of the locations of the Register File (LDRP 0, reg-i); on the contrary it is generated by the Fuzzy Core. The choice between the two possible fuzzy outputs is set by the FZSL configuration bit of REG_CONF6 register FZSL=0/1 means the starting value is the loaded from the FUZZY_OUT_0/1.
start
start stop
Level
start stop
start
Edge
Reset
Clock Counted Value
30/99
0
0
1
2
3
3
3
0
ST52T301/E301
Figure 7.2. Timer Peripheral Block Diagram
31/99
ST52T301/E301
Figure 7.3. Timer Internal Structure
32/99
ST52T301/E301
7.2 Timer Interrupt It is possible to enable the Timer Interrupt by software control.The Timer can be programmed to generate an Interrupt request until the end of the count or when there is an external TSTART signal. The Timer can generate programmable Interrupts in to 4 different modes: Interrupt mode 1: Interrupt on counter Stop. Interrupt mode 2: Interrupt on Rising Edge of TIMEROUT. Interrupt mode 3: Interrupt on Falling Edge of TIMEROUT. Interrupt mode 4: Interrupt on both edges of TIMEROUT. In order to program the interrupt mode INTSL, INTF and INTR bits of the REG_CONF7 must be set following the indications shown in the Table7.1.The Timer interrupt can be used to exit the MCU from the WAIT mode. 7.3 Timer Configuration The Timer configuration needs to set 4 registers of the Configuration Register Bench. CONF_REG4: TMLSB contains the less significative bits of the Prescaler starting value. CONF_REG5: TMMSB contains the more significative bits of the Prescaler starting value Figure 7.5. Timer Configuration Register 4 and 5 Figure 7.4. TIMEROUT Signal Type
Prescout*Counter
Timer Output Type 1
Type 2
Table 7.1. Timer Interrupt Setting
INTERRUPT MODE 1 2 3 4 INTSL 1 0 0 0 INTF X 1 0 1 INTR X 0 1 1
REG_CONF4 Timer
D7 D6 D5 D4 D3 D2 D1 D0
TMLSB - Prescaler Init Value Less Significative Bits
REG_CONF5 Timer
D7 D6 D5 D4 D3 D2 D1 D0
TMMSB - Prescaler Init Value More Significative Bits
33/99
ST52T301/E301
CONF_REG6: TMRST sets the internal INR signal. TMST sets the internal INS signal. IESL selects the source of the TRES and TSTART signals. IESL="0" signals are the internal INR and INS. IESL="1" signals come from the TRES and TCTRL pins. TMEL selects the TSTART signal allowing to work in Level Mode or in Edge Mode like previously described. TMEL="0" means Edge Mode TMEL="1" means Level Mode. CKSL selects the source of the TMRCLK (working Timer frequency). CKSL="0", the TMRCLK is the internal MCLK divided by the Prescaler starting value. CKSL="1", the TMRCLK is an external clock by TCLK pin. TMS TIMEROUT is a signal with frequency equal to the working Timer frequency divided by the starting value of the Prescaler (16 bit) and Counter (8 bit). The Timer output can be eithera square wave with duty-cycle 50% or a pulse signal (with the pulse durationequal to the Prescaler output signal period). TMS="1", TIMEROUT is a square wave TMS= "0", TIMEROUT is a pulse signal. POL defines the polarity of the Timer output signal (TIMEROUT). Figure 7.6. Timer Configuration Register 6
Table 7.2. Configuration Register 6 Description
Bit 0 Name TMRST 1 0 1 TMST 1 0 2 IESL 1 0 3 TMEL 1 0 4 CKSL 1 0 5 TMS 1 0 6 POL 1 7 not used Negative Polarity Square Wave (Type 1) Positive Polarity External Timer Clock Pulse Wave (Type 2) on Level Internal Timer Clock External Signals on Edge Start Internal Signals Start Stop Value 0 Stop Description
REG_CONF6 Timer
D7 D6 D5 D4 D3 D2 D1 D0
TMRST - Internal Timer Reset TMST IESL TMEL CKSL TMS POL not used - Internal Timer Start - Internal/External Signals Selector - Edge/Level Timer Abilitation - Internal/External Clock Select - Timer Output Shape - Timer Output Polarity
34/99
ST52T301/E301
CONF_REG7: INTSL It allows to select the interrupt mode for the Timer. INTSL="0" Interrupt is generated on the falling edge of the Counter Stop. INTSL="1" the interrupt is generated on the edges of TIMEROUT. INTF INTR INPSL selects the source of the value of the Counter between a location of the Register File and the Fuzzy Core. INPSL="0", Counter value coming from the FC. INPSL="1", Counter value coming from the RF. FZSL FZSL= "0", the valueof the TimerCounter is equal to FUZZY_OUT_0 FZSL= "1", the valueof the TimerCounter is equal to FUZZY_OUT_1 Table 7.3. Configuration Register 7 Description
Bit Name Value 0 0 INTSL 1 0 1 INTF 1 0 2 INTR 1 0 3 INPSL 1 0 4 FZSL 1 5 6 7 not used not used not used Timer Data Input coming from FUZZY_OUT_1 Timer Data Input coming from a Register File location Timer Data Input coming from FUZZY_OUT_0 INT_TMR on Rising Edge of TIMEROUT Timer Data Input coming from the Fuzzy Core INT_TMR on Falling Edge of TIMEROUT NO INT_TMR on Rising Edge of TIMEROUT INT_TMR on Edges of TIMEROUT NO INT_TMR on Falling Edge of TIMEROUT Description INT_TMR on Falling Edge of Counter Stop
Figure 7.7. Timer Configuration Register 7
REG_CONF7 Timer
D7 D6 D5 D4 D3 D2 D1 D0
INTSL INTF INTR INPSL FZSL not used not used not used - Interrupt Generator Selector - Interrupt on TIMEROUT Falling Edge - Interrupt on TIMEROUT Rising Edge - Input Data Selector - Fuzzy Input Selector
35/99
ST52T301/E301
8 I/O PORT ST52x301 is provided with dedicated lines for input/output.These lines, grouped into an 8-bit I/O Port P(0:7), can be programmed to provide parallel input/output with a handshake line (READY) to carry data in/out. The I/O Port is not able to perform operations on the single bit, and the communication cannot be performed at the same time in input and output. It is possible to program the parallel port direction by using the register REG_CONF0 in order to set which bits are in input and which are in output. T he po r t h a s a n i n t ern a l reg ist e r (PERIPH_REG_2) dedicated to hold output data coming from the Register File through an LDPR instruction. Input data are automaticallystored in the IN_PORT register, 6-th location of the Input Register. P8 pin is a digital output line available directly connected to the OUT bit of the REG_CONF1; then it can be set by using a LDCF instruction. (see table 8.2 and Figure 8.8) Figure 8.2. Figure 8.1.
TTL CMOS
INP_PORT(i) P(0:7) I/O PIN PERIPH_REG_2(i)
TRISTATE
IO(i) REG_CONF0(i)
OUT REG_CONF1(0)
P8 OUTPUT PIN
36/99
ST52T301/E301
8.1 I/O PORT CONFIGURATION REG_CONF0 allows dynamic change in I/O Port configurationduring program execution setting the communication direction of each bit. IOi setting equal to "0" configures the i-th bit of the P(0:7) I/O Port in input. Data coming from external digital devices are stored in the 6-th location (INP_PORT)of the Input register bench. IOi="1" sets the i-th bit of the port in output. Data stored in the i-th location of the Register File is written on the port by using the instruction: LDPR 2, regi Table 8.1. Configuration Register 0 Setting
Bit 0 Name IO0 1 0 1 IO1 1 0 2 IO2 1 0 3 IO3 1 0 4 IO4 1 0 5 IO5 1 0 6 IO6 1 0 7 IO7 1 Output Pin Output Pin Input Pin Output Pin Input Pin Output Pin Input Pin Output Pin Input Pin Output Pin Input Pin Output Pin Input Pin Output Pin Input Pin Value 0 Input Pin Description
Figure 8.3. Configuration Register 0
REG_CONF0 I/O Port
D7 D6 D5 D4 D3 D2 D1 D0
IO0 IO1 IO2 IO3 IO4 IO5 IO6 IO7 - I/O Communication Direction Bit - I/O Communication Direction Bit - I/O Communication Direction Bit - I/O Communication Direction Bit - I/O Communication Direction Bit - I/O Communication Direction Bit - I/O Communication Direction Bit - I/O Communication Direction Bit
37/99
ST52T301/E301
8.2 INPUT HANDSHAKE Figure 8.5 illustrates the timing associated with the READY Handshake signal, when the instruction LDRI reg 6 is performed. When the LDRI instruction is executed to read the port, ST52x301 resets the READY signal to indicate that it is not possible to change the input data during this phase of reading. To synchronizethe transmission with READY signal will prevent the INP_PORT data from changing while ST52x301 is reading the port. READ PORT signal represented in figure 8.5 is an ST52x301 internal signal. Input data on the port are continuously sampled and are strobed into the port only when READY is set. Figure 8.4. One Line Input Handshake
W.A.R.P .3TC
P(7:0)
DATA
EXTERNAL PERIPHERA L
I/O PORT R EADY
IOP
x
x
x
x
x
x
x
0
REG_CONF1
Figure 8.5. One Line Input Handshake Timing
CLK
READ PORT
PIO(7:0)
DATA IN
NEW DATA IN
READY
38/99
ST52T301/E301
8.3 OUTPUT HANDSHAKE Figure 8.7 illustrates the timing associated with the READY Handshake signal, when the instruction LDPR 2 reg is performed. WhenREADY is reset no significantdata are on the output port pins, because ST52x301 is writing into the PERIPH_REG_2. When the data is ready in PERIPH_REG_2, READY signal is set. The rising edge of READY signal can be used as a latching signal. No peripheral acknowledge is waited for. If the signal READY is high, it means that the data out is still not read.In this case, the following LDPR instruction is stored in a one register peripheral stack. If the READY is maintained high, the following LDPR instructions store the data coming from the Registers File on the same register stack. Figure 8.6. One Line Output Handshake
Figure 8.7. One Line Output Handshake Timing
39/99
ST52T301/E301
It means that each LDPR instruction deletesthe old value contained in the parallel port stack register and rewrite a newvalue on the same stack register. Only the last LDPR instruction is executed if the READY signal is maintained high during several LDRP instructions. Table 8.2 Configuration Register 1 Setting
Bit 0 1 ECKF 2 11 0 3 TXC 1 SCI End Transmission Interrupt Enabled SCI Transmission Data Register Empty Interrupt Disabled SCI Transmission Data Register Empty Interrupt Enabled SCI Break Error Interrupt Disabled SCI Break Error Interrupt Enabled SCI Overrun Error Interrupt Disabled SCI Overrun Error Interrupt Enabled SCI Received Data Register Full Interrupt Disabled SCI Received Data Register FullInterrupt Enabled 20 MHz SCI End Transmission Interrupt Disabled 01 10 10 MHz 20 MHz Name P8 Value 00 Description Digital Output Bit 5 MHz
0 4 TDRE 1
0 5 BRK 1 0 6 OVR 1 0 7 RDRF 1
Figure 8.8.
40/99
ST52T301/E301
9 SERIAL COMMUNICATION INTERFACE The Serial Communication Interface (SCI) integrated into the fuzzy processor ST52x301 provides a gene ral p urpose shift register peripheral, that allows to link several widely distributed MCUs, through their SCI subsystem. The SCI gives a serial interface providing communication with common baud rates, up to 38400 Hz, and flexible character format. The SCI is a full-duplex UART-type asynchronous system with standard Non Return to Zero (NRZ) format for the transmitted/received bit. The length of the transmitted word is 10/11 bits (1 start bit, 8/9 data bits, 1 stop bit). The SCI is composed of three modules: Receiver, Transmitter and Baud-Rate Generator and it is configured by means of Configuration Registers 3 and 1. 9.1 SCI RECEIVER BLOCK T he SCI Rec eive r b lo ck ma n ag e s t h e synchronization of the serial data stream and stores the data characters. The SCI Receiver is mainly formed by two sub-systems: Recovery Buffer Block and SCDR_RX Block. The RE configuration bit set to "1" (Configuration Register 3) enables the SCI Receiver. The SCI receives data coming from the RxD pin and drives the Recovery Buffer Block, that is a high-speed shift register operating at a clock frequency (CLOCK_RX) 16 times higher than the fixed baud rate (CLOCK_TX). This sampling rate, higher than the Baud Rate clock, allows to detect Figure 9.2. SCI Block Diagram
Figure 9.1. SCI transmitted word structures
41/99
ST52T301/E301
the START condition,theNoise errorand the Frame error. When the SCI Receiver is in IDLE status, it is waiting for the START condition, that is obtained with a logic level 0, consecutive to a logic level 1. This conditionis detected,if,with thefixedsampling time, three logic levels 0 are sampled after three logic levels 1. The recognition of the START bit forces the SCI Receiver Block to enter in an data acquisition sequence, according to serial mode. The 2 bits, M, of the ConfigurationRegister 3 allow to definethe serial mode with the conventionshown in table 9.2. The bit, T8, in caseof M = 10 is used to set the parity check to perform, as indicated in the previous table 9.2. The recognition of STOP condition allows to transfer the received data, from Recovery Bufferto SCDR_RX buffer, adding the eventual ninth data bit, according to the meaning shown in the previous table 9.2. After this operation, RXF flag of SCI Status Input Register 8 (fig. 9.3) is set to logic level 1. The Control Unit reads the data from SCDR_RX buffer (in read-only mode) with SRX instruction and provides a reset at logic level 0 to RDRF flag. If a data of Recovery Buffer is ready to be transferred into SCDR_RX buffer, but the previous one was not yet read by the Core, an OVERRUN Error takes place: the status flag OVERR indicates the error condition. In this case the information stored in SCDR_RX buffer is not altered, but the one that has caused the OVERRUN error can be overwritten by a new data coming from the serial data line. Recovery Buffer Block This block is structured as a synchronised finite state machine on the CLOCK_RX signal falling edge. When the Recovery Buffer Block is in IDLE state it waits for the reception of the correct 1 and 0 sequence representing the START. The recognition takes place by sampling the input RxD at CLOCK_RX f requency, that has a frequency 16 times higher than CLOCK_TX. For this reason, while the external transmitter sends a single bit, the Recovery Buffer Block samples 16 states (from SAMPLE1 to SAMPLE16).
Table 9.1 Configuration Register 3 Setting
Bit Name Value 0 0 TE 1 0 1 RE 1 00 2 M 01 10 3 11 9, No Parity, 1 bit stop Parity Odd, if Parity is selected (M = 10); otherwise 9th Data bit Parity Even, if Parity is selected (M = 10); otherwise 9th Data bit 600 Hz 1200 Hz 2400 Hz 4800 Hz 9600 Hz 19200 Hz 38400 Hz External Clock 8, No Parity, 2 bit stop 8, Parity, 1 bit stop Receiver ENABLED 8, No Parity, 1 bit stop Transmission ENABLED Receiver DISABLED Description Transmission DISABLED
0 4 T8 1
000 5 001 010 BRSL 6 011 100 101 110 7 111
42/99
ST52T301/E301
The analysis of RxD input signal is carried out looking three samples for each bits received.0 If these three samples are not equal, then the noise error flag, NSERR, of Input Register 8 is set to 1 and the received data value will be the one assumed by the majority of the samples. By means of the procedure described above, to avoid SCI becomes IDLE, because of a limited noise due t o an erroneous sampling, th e transmissionis recognizedas correct and the noise flag error is set. At the end of the cycle relative to the reception of a bit, Recovery Buffer Block will repeat the same steps 9 times: one step for each received bit, plus one for the stop acquisition(10 times in caseof 9-bit data, double stop or parity check). At the end of datareception,Recovery BufferBlock, will supply information on eventual frame errors by setting to 1 FRERR flag bit of Input Register 8. A frame error can occur if the parity check has not been successfully achieved or if STOP bit has not been detected. If Recovery Buffer Block receives 10 consecutive bits at logic level 0, a break error occurres, and interrupt routine request starts. SCDR_RX block It is a finite state machine synchronized with the falling edge of the clock master signal, CKM. The SCDR_RX block waits the signal of complete reception, from the Recovery Buffer, to load the word received. Moreover, the SCDR_RCX block loads the values of FRERR and NSERR flag bits (Input Register 8), and sets the RXF flag to 1. Using SRX instruction the data are transferred to Register File and RXF flag is reset to 0, to indicate SCDR_RX block is empty. If a new data arrives before the previous one has been transferred to Register File, an overrun error occurres and OVERR flag, of Input Register 8, is set to 1.
Table 9.2 Configuration Register 1 Setting
Bit 0 1 ECKF 2 11 0 3 TXC 1 SCI End Transmission Interrupt Enabled SCI Transmission Data Register Empty Interrupt Disabled SCI Transmission Data Register Empty Interrupt Enabled SCI Break Error Interrupt Disabled SCI Break Error Interrupt Enabled SCI Overrun Error Interrupt Disabled SCI Overrun Error Interrupt Enabled SCI Received Data Register Full Interrupt Disabled SCI Received Data Register FullInterrupt Enabled 20 MHz SCI End Transmission Interrupt Disabled 01 10 10 MHz 20 MHz Name P8 Value 00 Description Digital Output Bit 5 MHz
0 4 TDRE 1
0 5 BRK 1 0 6 OVR 1 0 7 RDRF 1
43/99
ST52T301/E301
Figure 9.3. SCI Status Input Register
9.2 SCI TRANSMITTER BLOCK The SCI Transmitter Block consists of the following underblocks: SCDR_TX and SHIFT REGISTER, synchronized, respectively, with the clock master signal (CKM) and the CLOCK_TX. The whole block receives through Configuration Register 3 (M bits) the settings for the following transmission modes (see table 9.1): 8-bit word and a single stop signal 8-bit word plus a paritybit and a singlestop signal 8-bit word plus a double stop signal 9-bit word In case of 9 bit frame transmission, the most significat ive bit arrives through T8 of th e Configuration Register 3. In an 8-bit transmission, instead, T8 is used to configure the SCI, according to information containedin M (see table 9.1):in particularto chose the polarity control (even or odds) to implement the parity check. After a RESET signal, RST, the SCDR_TX block is in IDLE state until it receivesenabling signal, TE=1, of Configuration Register 3. If TE=1, using STX instruction the data, to be transmitted, are transferred from Register File to SCDR_TX block and the flag of Input Register 8, TXEM, is reset to 0, to indicate SCDR_TX block is full. If the core supplies a new data, this could not be loaded in the SCDR_TX block until the current data has not been unloaded on the Shift Register block. This means that only when TXEM is 1, it is possible to load data in the SCDR_TX Block. When the SHIFT REGISTER Block loads the data to be transmitted on an internal buffer, TXEND is 44/99
reset to 0 to indicate the beginning of a new transmission. At the end of transmission TXEND is set to 1, allowing to load in the SHIFT REGISTER a new data coming from SCDR_TX. It is important to underline that TXEND = 1 does not mean SCDR_TX is ready to receivea newdata. For this reason it is better to utilise the TXEM signal to synchronize the STX instruction to the SCI TRANSMITTER block If ST52x301 core resets TE to 0, the transmission is interrupted, but the SCI Transmitter block completes the transmission in progress before to reset. 9.3 Baud Rate Generator Block The Baud Rate Generator Block performs the division of the clock master signal (CKM), in a set of synchronism frequencies for the serial bit reception/transmission on the external line. Table 9.1. shows the set of frequenciesselected by means of BRSL (Configuration Register 3). Reception frequency (CLOCK_RX) is 16 times higher than transmission frequency (CLOCK_TX) . If BRSL is equal to 111, CLOCK_RX and CLOCK_TX signals coincide with clock master, CKM.
ST52T301/E301
10 TRIAC/PWM DRIVER ST52x301 offers a peripheral able to generate a signal on pin 24, TRIACOUT, to drive an external device, like a TRIAC, a IGBT or a Power Mos. Triac/PWM driver can perform 3 different working modes according to REG_CONF10 bits, MODE (see Table 10.4): MODE = "01": PWM MODE = "10": Burst Mode Triac Control (Thermal Regulations) Note: in this case CKSL of REG_CONF10 must be set to "1x". (see Table 10.4) MODE = "11": Phase Angle Partialization Triac Control (Motor Control) The Triac/PWM Driver can be initialized by using a value fixed by a controlalgorithm, that can be either the output of a fuzzy inference or the result of an arithmetic calculus stored in the Register File. In the latter case, by using the LDPR 1,reg-i instruction, the value, contained in the i-th register of Register File, is stored in the Triac Driver/PWM peripheral register PERIPH_REG_1. Figure 10.1 shows the internal structure of Triac/PWM Driver. PWM Mode The PWM working mode is obtained by setting REG_CONF10 bits, MODE, at "01" value. It consists of a signal, with fixed period , whose duty cycle can be modified.
Figure 10.1. TRIAC/PWM Driver Simplified Block Diagram
45/99
ST52T301/E301
The PWM period can be generated, internally, by dividing the master clock or, externally, by using an external clock signal. In both cases, the clock signal is divided by a 16-bit Prescaler, managed by REG_CONF8 an d REG_CONF9 (see Figure 10.2). The duty cycle is fixedby a value,that can be either the output of a fuzzy inference or the result of an arithmetic calculus. In the first case, it can be loaded directly in the register of the peripheral, otherwise it can be stored in one location of the Register File for further manipulations and then used for the control of the PWM. Burst Mode It is based on turning on and off the TRIAC, for a fixed integer number of main voltage periods, in order to control the power transferred to the load. For this reason a Burst Mode TRIAC control consists of a signal, with a period, T, containing an integer number of the main voltage periods, whose duty cycle is proportional to the number of periods in which the TRIAC is ON (Duty Cycle). This kind of Triac control is mainly used for thermal regulation. Theduty cycle is fixedby a valuethat can be directly the output of a fuzzy inference or the result of an arithmetic calculus. In order to work in Burst mode, it is necessary to detect the pre-post zero-crossing of main voltage, by using an external inserting circuitry. The user can define the period T, by means of the internal 16-bit prescaler, setting REG_CONF8 and REG_CONF9 (see Figure 10.2).T is proportional to the main voltage period, it is in the range 0 to 21.8 sec (if the main frequency is 50Hz). The width and the polarity of the pulses can be programmed according to the Triac and the circuit characteristics. Phase Angle Partialization Mode This method is based on turning on the TRIAC only for a part (phase angle) of each main voltage period. When the phase angle is large the energy (power)supplied to the load is low, viceversa, when the phase angle is small the energy supplied to the load is high. The phase angle can be fixed by a fuzzy algorithm or by a value stored in the Register File. The phase angle is an 8-bit value. The peripheral is programmable in order to work with a main voltage frequency of 50 or 60 Hz.
Figure 10.2. TRIAC/PWM Configuration Register 8 and 9
REG_CONF8 TRIAC / PWM
D7 D6 D5 D4 D3 D2 D1 D0
TCLSB - Prescaler init value Least Significative Bits
REG_CONF9 TRIAC / PWM
D7 D6 D5 D4 D3 D2 D1 D0
TCMSB - Prescaler init value Most Significative Bits
46/99
ST52T301/E301
10.1 PWM GENERATOR WORKING MODE When REG_CONF10 (3:2) bits, MODE, are "01", the peripheral is programmed to work in PWM Mode. By using the 16-bit prescaler, the PWM period can be generated by dividing the internal master clock, or an external clock signal applied on the pin MAIN1, or the main voltage frequency, by using the circuit shown in Figure 10.6. NOTE: The external clock signal, applied on MAIN1 pin, must have a frequency at least three time smaller than the internal master clock. The clock source can be selected by using REG_CONF10(5:4)bits, CKSL(see Table 10.4 and Figure 10.9). If the clock source selected is not the main voltage frequency(CKSL=1x), MAIN2 pin can be configured as input or output, by using REG_CONF10(7) bit, IOSL (see Table 10.4). If MAIN2 is an output, on this pin it is possible to get the prescaler output signal Tck. The period of the PWM signal is obtained by using the following relation: T=256*Tck where Tck is the output of the 16-bit prescaler managed by REG_CONF8 and REG_CONF9 (see Figure 10.2). NOTE. In PWM working mode, the value N, stored in the 16-bit prescaler, must be in the range from 2 to 216-1 By using a 20 MHz clock master it is possible to obtain a PWM frequency in the range 1.2 Hz to 26.04 KHz. The value Ton is prop ortional to a value, INIT_VALUE, that can be a fuzzy output or a value Figure 10.3. PWM Functionament coming from Register File, according with the I NP SL a n d F Z S L c o nf igu rat io n b it s o f REG_CONF12 (see Table 10.6 and Figure 10.12). The Ton is equal to: Ton= INIT_VALUE*Tck. It means the Ton can be fixed by the control algorithm that can be either the output of a fuzzy inference or the result of an arithmetic calculus. In the second case, the data, stored in the i-th location of the Register File, can be loaded by using the instruction: LDPR 1, reg-i. If the INIT_VALUE is 255 the Toff is equal to Tck. Table 10.1. MODE - Triac/PWM Working Mode Settings
Value 01 10 11
Note:
(1)
Description PWM Driver Burst Mode Control (1) Phase Angle Control
REG_CONF10(5) must be set to "1"
Table 10.2. PWM Frequencies
MCLK Frequency 5 MHz 10 MHz 20 MHz 1/T min 0.3Hz 0.6 Hz 1.2 Hz max 6.51 kHz 13.02 kHz 26.04 kHz
T = 256 * Tck
Ton = INIT_VALUE* Tck Toff
TRIACOUT
47/99
ST52T301/E301
10.2 BURST MODE When REG_CONF10 (3:2) bits, MODE, are "10" the peripheral is programmed to work in BURST MODE. Notice that when you are working in Burst mode CKSL must be set to "1x". (see Table 10.4) A square wave, Tb, is generated with a duty cycle proportional to the power the user intends to transfer on the load. A pulse is generated for each zero crossing of the main voltage included in the Ton of the fixed period. Figure 10.4 shows the typical Burst Control working mode.The period T of the signal Tb (see Figure 10.4) is equal to 256*Tck. Thesignal Tckis generatedprogrammingthe 16-bit Prescaler, by REG_CONF8 and REG_CONF9 (see Figure 10.2). Tck is equal to the main voltage frequency (50 or 60 Hz) divided by N+1, where N value is from 0 to 216-1. The value Ton is prop ortional to a value, INIT_VALUE, that can be a fuzzy output or a value coming from Register File, according with the I NPS L a n d F Z S L c o nf ig urat io n b it s of REG_CONF12 (see Table 10.6 and Figure 10.12). On TRIACOUT pin is generated a sequence of pulses, programmed, by using REG_CONF11(0) bit, POL (see Table 10.5), in order to be positive or negative, to drive the Triac in different quadrants. The number of generated pulses, N_PULSES, is: N_PULSES = 2 [(N+1)*INIT_VALUE - N] where N is the value stored in the 16-bit pescaler. Then Ton = (N_PULSES / 2)* TPOWER LINE The first pulse is obtained during the first zero crossing of the main voltage and the last one is generated after INIT_VALUE*Tck clock pulses, where Tck is the Prescaler output, generated by Figure 10.4. Burst Working Mode
T = 256 * Tck
Ton
using the main voltage frequencyapplied to MAIN1 and MAIN2 pins. Theperipheral can be programmed in order to work with 50 or 60 Hz main voltage frequency, by setting the REG_CONF10(6) bit, PSF (see Table 10.4). Ranges of the Tb signal period depend on the power line frequency (see Table 10.3). In order to drive a Triac in Burst Mode it is required to generate a sequence of pulse, that must be centred on the zero crossing of the power line as shown in the Figure 10.7. For this reason, the pre zero crossing and the post zero crossing of the power line must be detected. To detect the zero-crossing and get also the main voltage frequency, the user must generate MAIN1 and MAIN2 signals, by using the circuit shown in Figure 10.6. MAIN1 and MAIN2 signals are used in the block called PULSE GENERATOR of the peripheral (see Figure 10.1). In particular the pulses are generated by using the rise edge of the signal MAIN1 and the falling edge of the signal MAIN2. Figure 10.5 shows the generation of the Triac pulses Tp . The first firing pulse for the Triac is generated on the zero crossing of the power line, while the next pulses are centred on the zero crossing. Table 10.3. TRIACOUT Signal Period
Power Line Frequency 50 Hz 60 Hz T min 5.12 s 4.26 s max 335544 s 279620 s
Tb
1.5 1 0.5
Power 0 Line -0.5
-1 -1.5
TRIACOUT
48/99
ST52T301/E301
Normally the Triac firing pulses start 1/3 Tp before the zero crossing and the lengthof the pulses is Tp, see Figure 10.5. The length Tp of the pulses is programmable by using UTP value, that is a 14-bits number, obtained with REG_CONF12(5:0) bits, UTPMSB, and REG_CONF13, UTPLSB (see figure 10.12 and table 10.6): UTP(13:0) = [UTPMSB(5:0) UTPLSB(7:0)] TP = TMCLK * UTP The value Tp is in the range 0 to 4.9 ms when the clock master is 20 MHz. According to REG_CONF11(0) configuration register bit, POL, it is possible to set the firing Figure 10.5. Burst Mode pulse polarity
1
MCLK Frequency 5 MHz 10 MHz 20 MHz
TP min 0.0012 ms 0.0006 ms 0.0003 ms max 19.6608 ms 9.8304 ms 4.9152 ms
pulses polarity; in order to obtain positive or negative gate Triac currents, allowing to work respectively in I and IV quadrants, or in the II and III quadrants (see Figures 10.5 and 10.12). To increase the immunity of the peripheral against the electrical noise of the main voltage, a pr og ramma ble ma sk ing t ime, by u s in g REG_CONF11(5:2) bits, TCMSK (see Table 10.5) Figure 10.7 Burst Mode Zero Crossing
1.5 1
0.5
Power Line
0
0.5
Main Voltage
(0.5)
0
(1)
Positive Triac Gate Current
Ig
II and III quadrants
-0.5 -1
Tp TMASK
Tp TMASK
Tp
TRIACOUT -1.5
Ig Negative Triac Gate Current I and IV quadrants 2/3 Tp 1/3 Tp Tp
MAIN2 MAIN1
Figure 10.6 Burst Mode Zero Crossing Circuit
49/99
ST52T301/E301
and Figure 10.11), is introduced after each firing pulse (see Figure 10.7): Masking time =(2^TCMSK*200 +100) nS. If TCMSK is 0 then Masking time is 0. In fact, to avoid the detection of electrical noise, during the masking time no signal, coming from MAIN1 and MAIN2, is taken into account. Working in the II and III quadrant the peripheral implements the following procedure: 1) The firing pulse is set to "1" on the rising edge of MAIN1. 2) The firing pulse is reset to "0" after the time Tp fixed by program. 3) The firing pulse is reset to "0" for a time equal to the fixed masking time. 4) On the falling edge of MAIN2 the firing pulse is set to "1" 5) The firing pulse is reset to "0" after the time Tp fixed by program. 6) The firing pulse is reset to "0" for a time equal to the fixed masking time. Following this approach it is possible to filter electrical noise and oscillations on the signal MAIN1 and MAIN2. It is possible to generate a programmable Interrupt in four different ways: 1) No Interrupt; 2) Interrupt on the rising edge of the signal Tb. 3) Interrupt on the falling edge of the signal Tb. 4) Interrupt on both the edge of the signal Tb. The Interrupt is programmable by using the register REG_CONF11(7:6), INTSL (see Table 10.5). Figure 10.8. Phase Angle Partialization Mode
1.5
TCMSK 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
MaskingTime 0 s 0.5 s 0.9 s 1.7 s 3.3 s 6.5 s 12.9 s 25.7 s 51.3 s 102.5 s 204.9 s 409.7 s 819.3 s 1638.9 s 3276.9 s 6553.7 s
10.3 PHASE ANGLE PARTIALIZATION WORKING MODE When REG_CONF10 (3:2) bits, MODE, are "11" the peripheral is programmed to work in PHASE ANGLE PARTIALIZATION mode. In this mode Triac is controlled each period of the main voltage. The power transferred to the load is proportional to the CURRENT FLOW ANGLE . This kind of Triac control is suitable to drive the Triac
VA2-A1 1
0.5
L
Loa d Il A2 A1
0 1.5 (0.5)
Phase Angle
Il1
(1)
N
0.5 (1.5) 0 (0.5) (1) (1.5)
Current Flow Angle
180
0
360
0
50/99
ST52T301/E301
with inductive load (i.e. universal or monophase motors). In the figure 10.8 is shown the relation between the Phase Angle and the Current flow angle . The peripheral allows to control the Phase Angle or equivalentlythe time T1 (see Figure 10.9). It is possibleto changeTime T1 settingthe contents of the peripheral register PERIPH_REG_1. This value could be directly loaded by using one of the two fuzzy outputs or by using a value coming from the Registers File, according with INPSL and FZSL configurationbits of REG_CONF12 (seeTable 10.6 and Figure 10.13). In order to synchronizethe peripheral with the zero crossing of the main voltage the two pins MAIN1 and MAIN2 must be connected together if the externalcircuit is the one shownin the Figure10.10. It is possible to use different circuits for the zero crossing detection, but the MAIN1 signal rising edge must be synchronized with a main voltage zero crossing and the MAIN2 signal falling edge Figure 10.9 Phase Angle Partialization mode
Mains 1.5 Voltage
1 0.5 0 (0.5) (1) (1.5)
Tr Tr/2 Ti
T1 T1 Tmax
8 mS 10 mS
20 mSec
must be synchronized with the following main voltage zero crossing, always. Theperipheral can be programmed in order to work with 50 or 60 Hz main voltage frequency by setting the REG_CONF10(6) bit, PSF (see Table 10.4). If main voltage frequencyis equal to 50 Hz, then Tr, see figure 10.9, is equal to 20 mSec and T1 is: T1 = PERIPH_REG_1(0:7)*(1/25.5)ms. The length of the semiperiod Ti/2 is programmable by using the registers REG_CONF12(0:5) and REG_CONF13, (see figure 10.12).By using a clock master equal to 20 MHz the pulse width is in the range from 0.2 to 250 s. The duty cycle of Ti is always 50 %. In order to avoid problems for the Triac firing when the load is inductive 8 different pulses are generated by the peripheral. If the time T1 is bigger than a fixed time Tmax then no pulses are generatedand the Triacis maintained off. This feature was implemented in order to avoid the firing of the Triac in the second half period of the main voltage. The firing pulses are generated when the contents of the PERIPH_REG_1 is less or equal to 204, otherwise they are not generated. When the frequency of the main voltage is 50 Hz, T1max is equal to 8 mSec. It is possible to generate a programmable interrupt in four different ways: 1) no Interrupt; 2) Interrupt on the rising edge of the signal MAIN1 3)Interrupt on the falling edge of the signal MAIN2 4) Interrupt on both the edges of the signal MAIN1. The Interrupt is programmableby using the register REG_CONF11(7:6), INTSL 10.4.TRIAC/PWM DRIVER PROGRAMMING
Figure 10.10 Phase Angle Partialization Zero Crossing
51/99
ST52T301/E301
It is possible SET or RESET the TRIAC/PWM Peripheral by using the REG_CONF10(0) bit, TCRST (see Table 10.4). If TRIAC/PWM Peripheral is SET, It is possible START or STOP it, by using the REG_CONF10(1) bit, TCST (see Table 10.4), to start or stop the internal counter without resetting it. It is possible to enablethe TRIACOUT, byusing the REG_CONF11(0) bit, TCTRS (see Table 10.5 and Figure 10.11). IF TCTRS is 0 the TRIAC/PWM Peripheraloutput is in tristate status. Table 10.5 Configuration Register 11 Description
Bit Name Value 0 0 POL 1 0 1 2 3 4 5 00 No Interrupt source selected Interrupt on falling edge of the TRIAC/PWM signal, or of the Main Voltage Interrupt on rising edge of the TRIAC/PWM signal, or of the Main Voltage Interrupt on both of edges of the TRIAC/PWM signa,l or of the Main Voltage TCMSK TCTRS 1 TRIACOUT status = Enabled Masking time =(2^TCMSK*200 +100) nS. TCMSK=0 Masking time=0 Output pulse Polarity = negative TRIACOUT status = Tristate Description Output pulse Polarity = positive
Table 10.4 Configuration Register 10 Description
Bit 0 Name TCRST 1 0 1 TCST 1 00 2 MODE 3 11 00 4 CKSL 5 01 1x External Clock on MAIN1 Main Voltage Frequency Phase Partialization 01 10 PWM signal Generator Burst Mode
(1)
6 01
Value 0
Description Triac Reset Triac Set Triac Stop Triac Start not used 7 11 INTSL 10
Table 10.6. Configuration Register 12 Description
Bit Clock Master 0/5 Name UTPMSB Value Description Output Impulse Width most significative bits TRIAC/PWM Input from Fuzzy Output TRIAC/PWM Input from Register File TRIAC/PWM Input from Fuzzy Output 1 TRIAC/PWM Input from Fuzzy Output 2
0 6 INPSL 1 0 7 FZSL 1
0 6 PSF 1 0 7
Note:
(1)
Main Power at 50 Hz Main Power at 60 Hz MAIN2 Input pin MAIN2 Output pin
IOSL 1
CKSL must be set to "1x"
52/99
ST52T301/E301
Figure 10.11. TRIAC/PWM Configuration Register 10
Figure 10.12 TRIAC/PWM Configuration Register 11
Figure 10.13 TRIAC/PWM Configuration Registers 12 and 13
53/99
ST52T301/E301
11 ELECTRICAL CHARACTERISTICS Absolute Maximum Ratings This product contains devices to protect the inputs against damage due to high static voltages, however it is advised to take normal precaution to avoid any voltage higher than maximum rated voltagees. For proper operation it is recommended that VI and VO must be higher than VSS and smaller than VDD. Reliability is enhanced if unu sed inputs are connected to an appropriated logic voltage level
Table 11.1. Absolute Maximum Ratings
Symbol VDD VI VO VDDA, VSSA VPP IO TRIACOUT Output Source Sink Current TOPT TSTG Operating Temperature Storage Temperature Supply Voltage Input Voltage Output Voltage Analog Supply Voltage EPROM Programming Voltage Standard Output Source Sink Current
(2)
Parameter
Value -0.5 to 7 VSS-0.3 to VDD+0.3 (1) VSS-0.3 to VDD+0.3 VSS-0.3 to VDD+0.3 13 20 80 (3) 0 to +85 -65 to +150
(1) (1)
Unit V V V V V mA mA C C
Note: Stresses above those listed in the Table "Absolute Maximum Ratings" may cause permanent damage to the device. These are stress ratings only and operation of the device at these or any other conditions above those indicated in the Operating sections of this specification is not implied. Exposure to Absolute Maximum Rating conditions for extended periods may affect device reliability. Refer also to the SGS-THOMSON SURE Program and other relevant quality documents. 1. Wit hin these limits, clamping diodes are garanteed to be not conductive. 2. All except TRIACOUT pin 3. For not more than 1 sec.
54/99
ST52T301/E301
(VSS or VDD) RECOMMENDED OPERATING CONDITIONS (Operating Condition: VDD=5V5%-TA=0 C to 85 C, unless otherwise specified) Table 11.2. Recommended Operation Condition
Symbol V DD VPP VO Parameters Operating Supply Voltage Programming Voltage Ouput Voltage Vss VSSA < VDDA VDD Test Conditions Min 4.75 11.4 VSS VSS 5 10 Typ 5.0 12 Max 5.25 12.6 VDD VDD 20 Unit V V V V MHz
VDDA, VSSA Analog Supply Voltage fOSC Oscillator Frequency (1)
Notes:
1. For correct behaviour of some peripherals, it is possible to work only with one of the 5 - 10 - 20 MHz frequencies.
55/99
ST52T301/E301
DC ELECTRICAL CHARACTERISTICS (Operating Condition: VDD=5V5%-TA=0 C to 85 C, unless otherwise specified)
Table 11.3 DC Electrical Characteristics
Symbol Parameter TTL type Schmitt trig. Low Level Input Voltage VIL CMOS type Schmitt trig. Low Level Input Voltage TTL type Schmitt trig. High Level Input Voltage V IH CMOS type Schmitt trig. High Level Input Voltage Standard Low Level Output Voltage VOL TRIACOUT Low Level Output Voltage Standard High Level Output Voltage VOH
(1) (1)
Test Conditions VDD =4.75 V see fig.11.6 VDD =4.75 V see fig.11.7 VDD =5.25 V see fig.11.6 VDD =5.25 V see fig.11.7 IOL =4mA IOL =50mA IOL =-4mA IOL =50mA see fig. 11.6 see fig. 11.7 VI=VSS VI=VDD VO=VSS or VDD VPP connected with VDD; VRESET =VSS FOSC= 10 MHz VPP connected with VDD; FOSC= 10 MHz VPP connected with VDD; VRESET =VSS FOSC= 10 MHz VPP connected with VDD; FOSC= 10 MHz
Min
Typ
Max 0.7
Unit V
1.2 2
V V
3.5 0.4 2 VDD-0.5 VDD-2 1.2 2.0 -1 +4 10
V V V V V V V A A mA
TRIACOUT High Level Output Voltage
TTL type Schmitt trig. Hysteresis Voltage VHys CMOS type Schmitt trig. Hysteresis Voltage IIL IIH IOL Low Level Leakage Input Current High Level Leakage Input Current Tri-State Output Leakage Current
Supply Current in RESET mode IDD Supply Current in RUN mode
11
mA
11
mA
Analog Supply Current in RESET mode IDDA Analog Supply Current in RUN mode
3
mA
10
mA
56/99
ST52T301/E301
AC ELECTRICAL CHARACTERISTICS (Operating Condition: VDD=5V5%-TA=0 C to 85 C, unless otherwise specified) Table 11.4. AC Electrical Characteristics
Symbol RS CIN COUT Parameter Input protection Resistor Input Capacitance Output Capacitance Test Conditions All Input Pins All Input Pins All Ouput Pins Min Typ 1 10 10 Max Unit k pF pF
Table 11.5. Timing Parameters
Symbol fOSC tCLH tCLL tSET tHLD tWRESET tWINT tIR tIF tOR tOF Parameters Oscillator Frequency Clock High Clock Low Setup Hold Minimum Reset Pulse Width Minimum External Interrupt Pulse Width Input Rise Time Input Fall Time Output Rise Time Output Fall see fig.11.2 see fig.11.2 CLOAD=10 pF see fig.11.2 CLOAD=10 pF see fig.11.2 10 10 see fig 11.1 see fig. 11.1 100 100 15 15 25 25 5 5 Test Conditions Min Typ Max 20 Unit MHz ns ns ns ns ns ns ns ns ns ns
Figure 11.1. Data Input Timing
Figure 11.2. I/O Rise and Fall Timing
57/99
ST52T301/E301
Figure 11.3. Input Pin Equivalent Circuit
Figure 11.4. Equivalent Tristate Output Circuit
Figure 11.5. Equivalent Output Circuit
58/99
ST52T301/E301
Figure 11.6. TTL-level Input Schmitt Trigger
Figure 11.7. CMOS-level Input Schmitt Trigger
Note: Only for RETE1 and RETEIO signals
TIMER CHARACTERISTICS (Operating Condition: VDD=5V5%-TA=0 C to 85 C, unless otherwise specified)
Table 11.7. Timer Characteristics
Symbol tRES fIN tW Resolution External Input Frequency on timer Internal Input Frequency on timer Pulse Width on TIMEROUT pin 1/FOSC Parameter Min 1/FOSC 20 Typ Max Unit s MHz s
59/99
ST52T301/E301
A/D CONVERTER CHARACTERISTICS (Operating Condition: VDD=5V5%-TA=0 C to 85 C, unless otherwise specified)
Table 11.8. A/D Converter Characteristics
Symbol Res ATOT tC VAN VZI VFS V FS% ADI ACIN
(2)
Parameter Resolution Total Accuracy (1) Conversion Time Conversion Range Zero Scale Voltage Full Scale Voltage (bandgap) Full Scale Voltage (bandgap) precision v/s VDDA variation Analog Input Current during Conversion Analog Input Capacitance Analog Source Impedance Output Reference Impedance Output Reference Load Analog Reference Load Capacitance
Test Conditions
Min
Typ 8
Max
Unit bit LSB s
FOSC > 5 MHz FOSC > 10 MHz FOSC > 20 MHz FOSC =5 - 10 - 20 MHz VSSA Conversion result= 00 Hex Conversion result= FF Hex VDDA=5V5% fOSC = 20 MHz
2 32 2.5 VSSA 2.474 1 2 2 1 100 0.1 10
V V V % pF k mA pF
ASI ORI ORL ORLC
Source-Off and Drain-Off Leakage Currents are in the range of nA. Notes: 1. Noise at VDDA, VSSA <40 mV 2. Excluding Pad Capacitance.
60/99
ST52T301/E301
INSTRUCTION SET
ADD
Addition
Format: Operation: ADD regi, regj regi <- regi + regj
Description: The contents of the Register File j-th register specified as source is added to the destination i-th register, leaving the result in the destination register. The result is 255 if overflow occurs. Flags: Z set if result is zero, cleared otherwise. S set if overflow, cleared otherwise. 2 7 If the register 4 contains the value 45 and the register 11 contains the value 15, then the instruction ADD 4,11 1001000 0100|1011 causes the register 4 of the Register File to be loaded with the value 60. If the register 4 contains the value 200 and the register 11 contains the value 100, the instruction causes the register 4 to be loaded with the value 44 (result-256) and the S flag to be set
Bytes: Cycles: Example:
61/99
ST52T301/E301
AND
Logical AND
Format: Operation: AND regi, regj regi <- regi AND regj
Description: The instruction logically ANDs the contents of the Register File j-th register specified as source and the destination i-th register in the Register File, leaving the result in the destination register. Flags: Z set if result is zero, cleared otherwise. S not affected. 2 7 If the register 4 contains the value 10011100 and the register 12 contains the value 01010101, then the instruction AND 4,12 10010001 0100|1100 causes the register 4 of the Register File to be loaded with the value 00010100.
Bytes: Cycles: Example:
62/99
ST52T301/E301
CON
Consequent
Format: Operation: CON cost Dividend Register <- Dividend Register + cost*teta Divisor <- Divisor + teta
Description: This intruction computes the values to add in the defuzzification registers, at the end of the single rule. The specified constant is the crisp value representing the output crisp membership function: it is multiplied by the last fuzzy operation result.
63/99
ST52T301/E301
DATA
Membership Functions data
Format: Operation: DATA var mbf lvd vtx rvd ADM location 16*var+mbf ADM location 16*var+mbf+64 ADM location 16*var+mbf+128 <- lvd <- vtx <- rvd
Description: This instruction is a pseudo instruction (it does not correspond to any operation executed by the processor) that allows to store membership functions data in the ADM (Antecedent Data Memory). The var and the mbf data identify the membership function. The lvd data is the left semibase distance of the M.F., the vtx data is the position of the vertex and rvd is the right semibase distance.
64/99
ST52T301/E301
FZAND
Fuzzy AND
Format: Operation: FZAND K <- stack0 AND stack1
Description: This instruction computes the AND operation between the two values stored in the fuzzy stack, previously loaded with LDP, LDN or LDK instructions, and stores it in the register K.
65/99
ST52T301/E301
FZOR
Fuzzy OR
Format: Operation: FZOR K <- stack0 OR stack1
Description: This instruction computes the OR operation between the two values stored in the fuzzy stack, previously loaded with LDP, LDN or LDK instructions and stores it in the register K.
66/99
ST52T301/E301
IRQ
Interrupt Vector
Format: Operation: IRQ int label interrupt vector <- label (PC = Program Counter)
Description: This instruction allows to specify the interrupt int service routine start address at label location. Flags: Bytes: Cycles: Example: Z,S not affected. 2 6 The instruction: IRQ 1 IntRout1 determinates that if interrupt 1 is serviced, the program counter (PC) is loaded with the memory address value labelled with IntRout1. The instruction IRQ is a dummy instruction used to store data in the chip memory. It is neither stored in memory nor executed.A series of IRQ instructions must be ended by a dummy end operation.
Remark:
67/99
ST52T301/E301
IRQM
Mask Interrupt
Format: Operation: IRQM mask interrupt mask register <- mask
Description: The interrupts are masked with the specified mask. Flags: Bytes: Cycles: Example: Z,S not affected. 2 6 The instruction: IRQM 10 1011|1110 00001010 enables the interrupts 1 and 3 and disables all the others.
68/99
ST52T301/E301
IRQP
Interrupt Priority
Format: Operation: IRQP cost interrupt priority register <- cost
Description: The interrupts priority is set according the specified values. Flags: Bytes: Cycles: Example: Z,S not affected. 2 6 The instruction: IRQP 198 1011|1111 11|00|01|10 determines the interrupt 2 to have highest priority, interrupt 1 medium priority and interrupt 0 lower priority. each couples of bits must have different values, that is interrupts must have different priority level.enables the interrupts 1 and 3 and disables all the others.
Remark:
69/99
ST52T301/E301
JP
Unconditional Jump
Format: Operation: JP addr PC <- addr (PC = Program Counter)
Description: The instruction replaces the PC value with the specified value causing an unconditional jump to another location in the program memory. Flags: Bytes: Cycles: Example: Z,S not affected. 2 6 The instruction: JP 1123 1010|0100 01100011 causes the PC to be loaded with the value 1123 and the program to continue from that location.
70/99
ST52T301/E301
JPNS
Jump on Non Sign Flag
Format: Operation: JPNS addr if S=0, PC <- addr (PC = Program Counter)
Description: If the S flag is cleared then the PC value is replaced with the specified value, causing a jump to another location in the program memory. Flags: Bytes: Cycles: Example: Z,S not affected. 2 6 If the S flag is cleared then the instruction: JPNS 1123 1111|0100 01100011 causes the PC to be loaded with the value 1123 and the program to continue from that location.
71/99
ST52T301/E301
JPNZ
Jump on Non Zero Flag
Format: Operation: JPNZ addr if Z=0, PC <- addr (PC = Program Counter)
Description: If the Z flag is cleared then the PC value is replaced with the specified value, causing a jump to another location in the program memory. Flags: Bytes: Cycles: Example: Z,S not affected. 2 6 If the Z flag is cleared then the instruction: JPNZ 1123 1101|0100 01100011 causes the PC to be loaded with the value 1123 and the program to continue from that location.
72/99
ST52T301/E301
JPS
Jump on Sign Flag
Format: Operation: JPS addr if S=1, PC <- addr (PC = Program Counter)
Description: If the S flag is set then the PC value is replaced with the specified value, causing a jump to another location in the program memory. Flags: Bytes: Cycles: Example: Z,S not affected. 2 6 If the S flag is set then the instruction: JPS 1123 1110|0100 01100011
causes the PC to be loaded with the value 1123 and the program to continue from that location.
73/99
ST52T301/E301
JPZ
Jump on Zero Flag
Format: Operation: JPZ addr if Z=1, PC <- addr (PC = Program Counter)
Description: If the Z flag is set then the PC value is replaced with the specified value, causing a jump to another location in the program memory. Flags: Bytes: Cycles: Example: Z,S not affected. 2 6 If the Z flag is set then the instruction: JPZ 1123 1110|0100 01100011
causes the PC to be loaded with the value 1123 and the program to continue from that location.
74/99
ST52T301/E301
LDCF
Load Constant into Configuration Register
Format: Operation: LDCF conf, const conf <- const
Description: The immediate constant value (const) specified as source is loaded into the destination peripheral configuration register (conf). Flags: Bytes: Cycles: Example: Z,S not affected. 2 6 The instruction: LDCF 5,43 1011|0101 00101011
causes the peripheral configuration register 5 to be loaded with the value 43.
75/99
ST52T301/E301
LDK
Load Stack with K register
Format: Operation: LDK stack0 <- K
Description: This instruction loads in the stack the value temporarily stored in the register K that is the result of the last fuzzy operation.
76/99
ST52T301/E301
LDM
Load Stack with M register
Format: Operation: LDM stack0 <- M
Description: This instruction loads in the stack the value temporarily stored in the register M with a SKM operation.
77/99
ST52T301/E301
LDN
Load Negative alpha value
Format: Operation: LDN var mbf stack <- 15 - computed alpha value related to mbf M.F. of var Variable
Description: This instruction performs the fuzzyfication and loads in the stack the negated alpha value of the M.F. mbf of var Variable.
78/99
ST52T301/E301
LDP
Load Positive alpha value
Format: Operation: LDP var mbf stack <- computed alpha value related to mbf M.F. of var Variable
Description: This instruction performs the fuzzyfication and loads in the stack the alpha value of the M.F. mbf of var Variable.
79/99
ST52T301/E301
LDPR
Load Register into Peripheral Register
Format: Operation: LDPR per, reg per <- reg
Description: The contents register specified as source (reg) is loaded into the destination peripheral register (per). Flags: Bytes: Cycles: Example: Z, S not affected. 1 5 (6 if parallel port with H/S is addressed) If the register 7 of the Register File contains the value 25 then the instruction: LDPR 2,7 01|10|0111
causes the register 2 of the Peripheral Register (i.e. parallel port) to be loaded with the value 25.
80/99
ST52T301/E301
LDRC
Load constant into Register
Format: Operation: LDRC reg, const reg <- const
Description: The immediate constant value specified as source is loaded into the destination register in the Register File. Flags: Bytes: Cycles: Example: Z,S not affected. 2 6 The instruction: LDRC 5,43 1000|0101 00101011
causes the register 5 of the Register File to be loaded with the value 43.
81/99
ST52T301/E301
LDRI
Load Input register into Register file
Format: Operation: LDRI reg, inp reg <- inp
Description: The contents of a input register specified as source (inp) is loaded into the destination register in the Register File (reg). Flags: Bytes: Cycles: Example: Z,S not affected. 2 6 If the register 2 of the A/D converter contains the value 25 then the instruction: LDRI 5,2 000|xxxxx 0101|0010 x = don't care
causes the register 5 of the Register file to be loaded with the value 25.
82/99
ST52T301/E301
LDRR
Load Register into Register
Format: Operation: LDRR regi, regj regj <- regi
Description: The contents of the Register File j-th register specified as source is loaded into the destination i-th register. Flags: Bytes: Cycles: Example: Z,S not affected. 2 6 If the register 2 of the Register File contains the value 25 then the instruction: LDRR 5,2 100101100101|0010
causes the register 5 of the Register file to be loaded with the value 25.
83/99
ST52T301/E301
MDGI
Macro Disable Global Interrupt
Format: Operation: MDGI MGI bit <- 0
Description: All the interrupts are disabled by this instruction. This instruction is used by FUZZYSTUDIOTM 3.0 Compiler macros to disable interrupt during macro execution. Flags: Bytes: Cycles: Example: Z,S not affected. 1 4 After the instruction: MDGI 10011010
all the interrupts cannot be acknowledged and remain pending
84/99
ST52T301/E301
MEGI
Macro Enable Global Interrupt
Format: Operation: MDGI MGI bit <- 1
Description: The not masked interrupts are enabled by this instruction only if a UDGI instruction has not specified before, not followed by a UEGI instruction. This instruction is used by FUZZYSTUDIOTM 3.0 Compiler macros to disable interrupt during macro execution. Flags: Bytes: Cycles: Example: Z,S not affected. 1 4 After the instruction: MEGI 10011011
not masked interrupts can be acknowledged if the interrupts are not globally disabled by the UDGI instruction
85/99
ST52T301/E301
OUT
Output computation
Format: Operation: OUT const Output Register const <- defuzzyfication result of the const output
Description: This instruction performs the defuzzyfication of the specified output (const can assume only the values 0 or 1) and loads in the correspondent Fuzzy Output Register the result.
86/99
ST52T301/E301
RETI
Return from Interrupt
Format: Operation: RETI PC <- stack Z <- stack S <- stack
Description: This instruction resumes the program execution exactly at the point it was left when an interrupt occurred. Z and S flag are set to the status they had when the interrupt service routine was started. Flags: Bytes: Cycles: Example: Z,S restored to the original setting before an interrupt occured. 1 5 If the PC stack contains the value 1123 and the program is processing an interrupt service routine, then the instruction RETI 10010101
causes the PC to be loaded with the value 1123 and the flags to be restored to the status before the interrupt occurred.
87/99
ST52T301/E301
RINT
Reset Interrupt
Format: Operation: RINT int cancel pending interrupt n. int
Description: The specified pending interrupt is cancelled if not currently in service. Flags: Bytes: Cycles: Example: Z,S not affected. 1 4 The instruction: RINT 2 0001|x|010 x = don't care
causes the bit 2 of the interrupt pending register to be cleared so that the interrupt 2 is not acknowledged.
Remark:
The use of RINT istruction has no effect if a specified interrupt has already been aknowledged and related service routine has not been completed.
88/99
ST52T301/E301
SKM
Store K register in M register
Format: Operation: SKM M <- K
Description: This instruction stores the result of the last performed fuzzy operation (stored in the temporary register K) in the temporary buffer M.
89/99
ST52T301/E301
SRX
SCI Reception
Format: Operation: SRX regi regi <- SCDR_RX
Description: The contents of the SCDR_RX block of the SCI receiver block, is transferred in the Register File i-th register specified as destination. Flags: Bytes: Cycles: Example: Z,S not affected. 2 5 If the SCDR_RX block of the SCI receiver block contains the value 45, then the instruction SRX 4 00101101
causes the register 4 of the Register File to be loaded with the value 45.
90/99
ST52T301/E301
STOP
Stop Program Execution
Format: Operation: STOP Stop section
Description: This instruction separates arithmetic instructions and fuzzy instructions. Also it ends a IRQ specification section. Flags: Bytes: Cycles: Example: Z,S not affected. 1 4 The instruction: STOP 10010111
if put after arithmetic instructions, it allows to start a block of fuzzy instruction and vice versa.
91/99
ST52T301/E301
STX
SCI Transmission
Format: Operation: STX regi SCDR_TX <- regi
Description: The contents of the Register File i-th register specified as source is transferred in the SCDR_TX block of the SCI transmitter block, to be transmitted. Flags: Bytes: Cycles: Example: Z,S not affected. 2 5 If the register 4 contains the value 45, then the instruction STX 4 00101101
causes the serial transmission of 45.
92/99
ST52T301/E301
SUB
Subtraction
Format: Operation: SUB regi, regj regi <- regi -regj
Description: The contents of the Register File j-th register specified as source is subtracted from the destination i-th register, leaving the result in the destination register. Flags: Z set if result is zero, cleared otherwise. S set if underflow, cleared otherwise. 2 7 If the register 4 contains the value 45 and the register 11 contains the value 15, then the instruction SUB 4,11 10010010 0100|1011 causes the register 4 of the Register File to be loaded with the value 30. If the register 4 contains the value 100 and the register 11 contains the value 200, the instruction causes the register 4 to be loaded with the value 156 (result+256) and the S flag to be set.
Bytes: Cycles: Example:
93/99
ST52T301/E301
SUBO
Subtraction with Offset
Format: Operation: Description: SUBO regi, regj regi <- regi - regj +128 The contents of the Register File register specified as source are subtracted from the destination register in the Register File, the value 128 is added to the result that is stored in the destination register. This operation allows the use of the signed byte considering the values between 0 and 127 as negative, 128 as 0, and the values between 129 and 255 as positive. Z set if result is zero or if overflow occurs, cleared otherwise. S set if underflow or overflow, cleared otherwise. 2 7 If the register 4 contains the value 45 and the register 11 contains the value 15, then the instruction SUBO 4,11 10010011 0100|1011 causes the register 4 of the Register File to be loaded with the value 158. The value 45 corresponds to -83, the value 11 corresponds to -113; so the operation is equivalent to perform -83 - (-113) = 30. As a matter of fact the result 158 corresponds to the value 30. If the register 4 contains the value 50 and the register 11 contains the value 200, the instruction causes the register 4 to be loaded with the value 234 (result+256) and the S flag to be set. If the register 4 contains the value 200 and the register 11 contains the value 50, the instruction causes the register 4 to be loaded with the value 22 (result-256) and the S and Z flags to be set.
Flags:
Bytes: Cycles: Example:
94/99
ST52T301/E301
UDGI
User Disable Global Interrupt
Format: Operation: UDGI UGI bit <- 0
Description: All the interrupt are disabled by this instruction. Flags: Bytes: Cycles: Example: Z,S not affected. 1 4 After the instruction: UDGI 10011000 all the interrupts cannot be acknowledged and remain pending.
95/99
ST52T301/E301
UEGI
User Enable Global Interrupt
Format: Operation: UEGI UGI bit <- 1
Description: All the interrupts are enabled by this instruction. Flags: Bytes: Cycles: Example: Z,S not affected. 1 4 After the instruction: UEGI 10011001 not masked interrupts can be acknowledged if the interrupt are not globally disabled by the MDGI instruction.
96/99
ST52T301/E301
WAITI
Wait for interrupt
Format: Operation: WAITI Wait state
Description: This instruction causes the program to stop, without halting the peripherals, until an interrupt occurs.. Flags: Bytes: Cycles: Example: Z,S not affected. 1 4 The instruction: WAITI 10010100
halts the program execution leaving the peripherals running on, until an interrupt occurs.
97/99
ST52T301/E301
CLCC44 PACKAGE MECHANICAL DATA
DIM MIN A B C C1 c1 D d1 d2 E e e3 F F1 F2 M M1 R 16.26 1.27 12.50 0.431 0.762 0.965 0.508 1.016 0.762 1.82 0.889 2.362 16.76 .640 .050 .500 .017 .030 .038 .020 .040 .030 17.27 16.33 12.01 13.03 1.30 2.23 0.72 .035 .093 .660 mm TYP MAX 17.78 16.81 MIN .680 .643 .475 .513 0.52 .088 inch. TYP MAX .662 .662
98/99
ST52T301/E301
PLCC44 PACKAGE MECHANICAL DATA
DIM MIN A B C D d1 d2 E e e3 F F1 G M M1 1.16 1.14 14.99 1.27 1.27 0.46 0.71 0.101 0.046 0.045 17.4 16.51 3.65 4.2 2.59 0.68 16 0.590 0.050 0.500 0.018 0.028 0.004 mm TYP MAX 17.65 16.65 3.7 4.57 2.74 MIN 0.685 0.650 0.144 0.165 0.102 0.027 0.630 inch. TYP MAX 0.695 0.656 1.146 0.180 0.108
99/99
ST52T301/E301
ORDERING INFORMATION
PART NUMBER ST52E301/C ST52T301/P PACKAGE CLCC44-W PLCC44
Full Product Information at http://www.st.com Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by implication or otherwise under any patent or patent rights of STMicroelectronics. Specification mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information previously supplied. STMicroelectronics products are not authorized for use as critical components in lifesupport devices or systems without express written approval of STMicroelectronics. The ST logo is a registered trademark of STMicroelectronics (c) 1998 STMicroelectronics - Printed in Italy - All Rights Reserved FUZZYSTUDIO(R) is a registered trademark of STMicroelectronics DuaLogicTM is a trademark of STMicroelectronics MS-DOS(R), Microsoft(R) and Microsoft Windows(R) are registered trademarks of Microsoft Corporation. MATLAB(R) is a registered trademark of Mathworks Inc. STMicroelectronics GROUP OF COMPANIES Australia - Brazil - Canada - China - France - Germany - Italy - Japan - Korea - Malaysia - Malta - Mexico - Morocco - The Netherlands Singapore - Spain - Sweden - Switzerland - Taiwan - Thailand - United Kingdom - U.S.A.


▲Up To Search▲   

 
Price & Availability of ST52T301

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X